Regex Tester

Test JavaScript-compatible regular expressions against multiline text, inspect matches and capture groups, preview replacements, and copy plain-text results locally in your browser.

Regex Tester

Test JavaScript-compatible regular expressions locally in your browser.

Browser-local processing. Pattern, flags, test text, replacement text and results stay in this tab. A Worker is stopped after two seconds to keep ordinary tests from blocking the page.

Regular expression

Maximum 2048 characters. An empty pattern is valid and matches empty positions.

Runtime-supported flags: g, i, m, s, u, y, d. Duplicate or unsupported flags are rejected.

Maximum 200,000 characters. Newlines and Unicode are preserved.

Uses JavaScript replacement semantics, including capture references such as $1.

Results

Matches, capture groups, safe highlighting and replacement preview.

No test yet

Enter a pattern and test string, then select Test regex.

Steps

How to use

  1. Enter a JavaScript-compatible pattern such as (cat|dog)\s+\d+.
  2. Add flags such as g, i or m when the expression needs them.
  3. Paste sample text and select Test regex.
  4. Review matches, indexes, capture groups and the optional replacement preview.
  5. Copy the plain-text match or replacement summary only when the result is valid.
Examples and use cases
  • Find repeated words with \b(\w+)\s+\1\b and the gi flags.
  • Extract a value with ^name=(?<value>.+)$ and the m flag.
  • Preview a replacement using (\d{4})-(\d{2})-(\d{2}) and $3/$2/$1.
Privacy, limits and tool details

Key facts

Best use case
Testing JavaScript regular expressions against sample text before using them in code
Input
A pattern, JavaScript flags, test text and optional replacement string
Results
Match count, highlighted matches, indexes, capture groups and replacement preview
Processing method
Local evaluation in a dedicated Web Worker with a two-second time budget
Privacy model
Patterns, test text, groups and results stay in browser memory and are excluded from analytics
Limits
2,048-character pattern, 200,000-character test string and 1,000 matches
Main limitation
The evaluator follows the JavaScript RegExp dialect rather than PCRE, Python or .NET syntax
Privacy

Privacy and processing

Processing method: The browser validates the inputs and sends them to a dedicated Web Worker. The Worker uses the current JavaScript RegExp implementation, applies bounded result collection and returns only the information needed for the preview.

Privacy model: Patterns, test text, replacement text, capture groups and matches remain in the current browser tab. They are not uploaded, persisted or included in analytics.

Limitations

Limitations

  • The tool uses the JavaScript RegExp dialect; PCRE, Python and .NET features may not behave the same way.
  • Runtime support determines whether newer flags and syntax such as lookbehind or Unicode properties are available.
  • The limits reduce UI-freeze risk but cannot guarantee protection from every pathological pattern.
  • Replacement previews follow JavaScript String.prototype.replace semantics and the selected flags.
Features

Benefits

Worker-based evaluation

Keep regular-expression work away from the main UI thread with an explicit time limit.

Useful match detail

Inspect indexes, numbered groups, named groups and optional indices in one place.

Safe previews

Matched text is rendered as text and marks, never as user-controlled HTML.

Private by default

Your pattern and sample text stay in the browser and are excluded from analytics.

Tips

Pro tips

  • Start with a literal or short character class, then add quantifiers and groups one piece at a time.
  • Use the g flag for all matches and m when ^ or $ should apply to each line.
  • Use named groups when the captured value has a meaningful role in your code.
  • Test both matching and non-matching examples before publishing a pattern.
Watch out

Common mistakes to avoid

  • Using a pattern syntax from another regex flavor without checking JavaScript compatibility.
  • Forgetting the g flag when expecting more than the first match.
  • Writing a backslash in a JavaScript string without escaping it for that string literal.
  • Assuming a valid pattern must match every possible input.

Sources

Detailed Regex Tester guide

What is the Regex Tester?

ToolMint's Regex Tester evaluates JavaScript-compatible regular expressions against sample text in your browser. It shows the match count, highlighted matches, indexes, numbered and named capture groups, and an optional replacement preview.

The evaluation runs in a dedicated Web Worker. Patterns, test strings, replacement text and results stay in the current browser tab; they are not uploaded or included in analytics. The tool is useful for checking a pattern before placing it in application code, but you should still test it against representative inputs in your own project.

How to test a regular expression

  1. Enter a JavaScript-compatible pattern such as (cat|dog)\\s+\\d+.
  2. Add flags such as g, i, m or s when the pattern needs them.
  3. Paste plain-text sample data into Test string.
  4. Add a replacement string if you want to preview JavaScript replacement behavior.
  5. Select Test regex, then inspect the matches and output.

The pattern is limited to 2,048 characters, the test string to 200,000 characters, and the result to 1,000 matches. Evaluation has a two-second time budget. These limits keep normal testing responsive, but no limit can guarantee that every pathological expression will complete instantly.

JavaScript regex syntax

This tool follows the JavaScript RegExp implementation available in the current browser. It is not a universal PCRE, Python or .NET tester. Newer syntax, flags, lookbehind and Unicode property escapes depend on browser support.

Common examples include:

Pattern Use Flags
\\b(\\w+)\\s+\\1\\b Find a repeated word gi
^name=(?<value>.+)$ Capture a value on each line m
(\\d{4})-(\\d{2})-(\\d{2}) Capture date components g
^https?:// Check an HTTP or HTTPS prefix i

Use g when you need all matches rather than the first match. Use m when ^ and $ should apply to individual lines. Use s when supported and a dot should include line terminators. Duplicate or unsupported flags are rejected.

Matches and capture groups

Each match includes its text, starting index and length. Parenthesized groups are returned separately, and named groups retain their names. A valid expression can have zero matches; that means the pattern parsed successfully but did not find the requested structure in the supplied text.

The highlighted preview is rendered as text. Sample text that looks like HTML, an event handler or a script is not inserted as executable markup. Copy actions are available only after a valid evaluation and copy plain-text summaries or the replacement preview.

Replacement previews

Enter a replacement string to preview JavaScript String.prototype.replace semantics. References such as $1 and $<name> can use captured groups. The preview uses the selected flags, so a non-global pattern replaces the first match while a global pattern can replace every match.

Treat the preview as a check of JavaScript behavior, not as a guarantee for another regex flavor. Confirm the result with tests in the application that will run it.

Common mistakes

  • Copying a PCRE, Python or .NET pattern without adapting its syntax for JavaScript.
  • Forgetting g when expecting every occurrence.
  • Forgetting that a backslash must be escaped again when a regex is written inside a JavaScript string literal.
  • Assuming a valid expression must match every test string.
  • Adding a broad nested quantifier without testing a long non-matching input.

Privacy and safety

Regex evaluation is local and does not call an API. The Worker is terminated after completion, failure, timeout, replacement input, reset or unmount. Analytics records only generic operation and outcome information; it does not receive the pattern, flags, test string, replacement, matched text, groups or error details.

The tool uses bounded inputs and results to reduce browser resource use. It does not promise protection from every expensive expression, so avoid pasting highly sensitive data and test potentially complex patterns with care. Verify generated replacement output before using it in production.

Use the JSON Formatter to inspect structured JSON, the JSON Schema Validator to check a JSON contract, the JSONPath Tester to query nested JSON, or the Text Diff Checker to compare sample outputs.

Sources

The FAQ section below is generated from the ToolMint registry so visible answers and FAQ structured data remain synchronized.

Frequently asked questions

The Regex Tester uses the JavaScript RegExp dialect available in your browser. It does not claim to implement every PCRE, Python or .NET feature.

Enter a pattern and optional flags, paste sample text, then select Test regex. The tool shows matches, indexes, capture groups and a replacement preview when the inputs are valid.

JavaScript returns one match for a non-global expression. Add the g flag when you want to collect all matches.

Yes. Paste multiline text and use the m flag when anchors should apply at line boundaries. The s flag is available when supported by the browser and makes dot match line terminators.

No. Evaluation runs locally in a dedicated browser Worker. Patterns, test text, replacement text and results are not uploaded or included in analytics.

The pattern may contain invalid JavaScript syntax, duplicate or unsupported flags, or exceed the input limit. The tester keeps error messages generic and does not expose stack traces.

A capture group is a parenthesized part of a pattern whose matched text is returned for inspection or can be referenced in a JavaScript replacement string.

No. A valid expression can return zero matches when the test string does not contain the requested structure.
7 min read Works in browser Privacy notes