Regex Tester
Test JavaScript regex, inspect capture groups, and preview replacements with a cancellable timeout.
This tool runs entirely in your browser. Your data is never uploaded, never stored, and never leaves your device.
Run JavaScript regex in a cancellable worker, inspect match positions and capture groups, and preview replacement text using the exact flags you choose.
How to use it
- 1Enter a pattern without slash delimiters and choose its JavaScript flags.
- 2Add sample text and an optional replacement, then run the test.
- 3Inspect match groups and the replacement result; cancel or revise a pattern that exceeds the timeout.
What happens to your data
Your expression and sample run in a local Web Worker using the browser's RegExp engine. Neither is uploaded; timed-out or cancelled workers are terminated rather than left running behind the page.
Last updated September 2026
Test a JavaScript regular expression against your own sample text and inspect what it actually matches. The pattern, flags, capture groups, match positions and replacement preview are kept together so you can debug a parser or find-and-replace rule without guessing which engine or hidden flag produced the result.
Flags are explicit. Without g, the match inspection reports the first match; with g, it scans subsequent matches. Case-insensitive, multiline, dot-all, Unicode and sticky behaviour are JavaScript behaviours, not PCRE or Python behaviours. Enter a pattern without enclosing slashes and set flags separately. Named capture groups are shown alongside numbered groups.
A problematic regex should not trap the page. Matching runs in a disposable Web Worker, with a timeout and a Cancel action. That protects the interface from catastrophic backtracking, but it is not proof that the same pattern is safe for a production server. Test your real input sizes and threat model in the engine that will run the expression.
How it works
The browser's RegExp constructor compiles the supplied pattern and flags inside an isolated worker. The worker reports matches, zero-based positions, capture groups and a replacement result. JavaScript replacement syntax includes $& for the full match, $1 for a numbered capture and $<name> for a named capture. Whether replacement affects one or several occurrences depends on the g flag.
Limits are a two-second timeout, 4,096 pattern characters, 200,000 input characters, 10,000 replacement characters, 128 capture groups, 1,000 displayed matches and two million output characters. If match or output limits are reached, the replacement is withheld instead of presented as a complete result. There is no evaluation of JavaScript pasted into the pattern field. Invalid syntax and flags become errors rather than an empty successful result. Input and result limits keep large match lists bounded; a terminated worker cannot continue burning CPU behind the page. Zero-length matching requires careful advancement so a global scan cannot loop forever.
Worked example: extract and replace order IDs
- Input
- Pattern: ORD-(?<id>\d+) Flags: gd Text: ORD-1042 ORD-2073 Replacement: Order $<id>
- Result
- Two matches, with named IDs 1042 and 2073. Replacement: Order 1042 Order 2073
The g flag scans both orders; d requests capture indices. Without g, only the first order is replaced.
Common use cases
- Debugging JavaScript regex replacement before editing a data file
- Checking named capture groups in a log parser
- Comparing the effect of global, multiline and case-insensitive flags
- Spotting patterns that time out on realistic sample input
Frequently asked questions
Which regular expression engine does this tester use?+
The JavaScript RegExp engine in your browser. It is not PCRE, Python re or .NET regex. Test engine-specific syntax in the environment where the pattern will actually run.
Why do I get one regex match instead of every match?+
The g flag is not added secretly. Without it, the match list shows the first match. Add g when you want to scan all occurrences; sticky y has its own positional behaviour.
Can I preview a regex replacement?+
Yes. Enter the replacement and inspect the result before copying or downloading it. JavaScript substitutions such as $&, $1 and $<name> refer to the full match, a numbered group and a named capture group.
Do I paste /pattern/gi into the pattern box?+
No. Paste the pattern without surrounding slashes and enter flags separately. Slashes in the pattern box are literal characters rather than delimiters.
Why did the regex test time out?+
Some patterns explore many possible backtracking paths on a particular input. The worker is stopped after the allowed time. Simplify the pattern and test it with realistic bounds; increasing a timeout alone does not make it production-safe.
Are match positions character or byte offsets?+
JavaScript string positions are zero-based UTF-16 code-unit offsets. Some characters, including many emoji, occupy two code units, so these are not byte positions or universal user-perceived character counts.
Standards and limitations
Used in these workflows
Related tools
Find & Replace
Replace every match at once, with case-sensitive, whole-word or regex options and a count of replacements.
Text Diff Checker
Compare two texts side by side. Highlight character, word, or line changes and download a private diff.
JSON Formatter & Validator
Format, validate, and minify JSON with exact line errors, a searchable tree, and private processing.
XML Formatter
Validate and format XML without rewriting attributes, CDATA or meaningful text spacing.