Regex Tester | JavaScript Pattern Matching & Capture Groups
Test JavaScript regular expressions instantly, see highlighted matches, and inspect numbered and named capture groups. Everything runs in your browser only — your pattern and text are never sent anywhere.
The pattern and text you enter are processed entirely in your browser and are never sent anywhere.
Result
Enter a pattern and a test string to see the matches instantly.
Match count:
The match count exceeded the limit (5,000), so only the first 5,000 matches are shown.
No matches found.
Highlighted text
Matches
How to use
- Enter a regular expression pattern and the flags you need (g, i, m, s, u).
- Enter the text you want to test against.
- The match count, highlighted text, and capture group values appear instantly.
How it works
Supported flags
- g (global): finds all matches. Without it, only the first match is returned.
- i (case insensitive)
- m (multiline):
^and$match the start/end of each line. - s (dotAll):
.also matches newline characters. - u (Unicode): treats surrogate pairs and
\u{...}escapes as single code points.
About the match results
For each match, the tool shows the matched text, its start position and length, plus the value and start position of every numbered capture group ((...)) and named capture group ((?<name>...)). A group that did not participate in the match is shown as "(did not participate)".
Catastrophic backtracking (ReDoS) mitigation and its limits
JavaScript's regular expression engine can take exponentially longer to process certain inputs (such as a long string that almost, but doesn't quite, match) when the pattern contains a "nested quantifier" — a group wrapped in a quantifier (+/*) that itself contains another quantifier, like (a+)+. This can freeze the browser tab for a long time, a problem generally known as catastrophic backtracking or ReDoS.
Before running your pattern, this tool checks for the typical nested-quantifier shape and refuses to execute it if found, showing an error instead. This check only covers the most common dangerous shape; there are patterns it cannot detect, such as combinatorial blowups from alternation (e.g. (a|aa)+). If the page becomes slow or unresponsive, close the tab and reopen it.
Input size limits
The pattern is limited to 1,000 characters and the text to 200,000 characters. With the global flag, the number of matches is capped at 5,000; anything beyond that is truncated.
Out of scope
This tool does not support replacement/substitution, natural-language explanations of a pattern, or switching to other languages' regex engines (Python, PHP, etc.). It focuses specifically on how a pattern behaves under JavaScript's regex engine.
FAQ
Is my pattern or text sent anywhere?
No. All regex matching happens entirely in your browser. Nothing is sent to any server.
Which flags are supported?
g (global), i (case insensitive), m (multiline), s (dotAll), and u (Unicode) are supported. The y (sticky) flag is not.
Why do some patterns produce an error?
Patterns containing a "nested quantifier" (a quantified group that itself contains another quantifier, like (a+)+) can trigger catastrophic backtracking, making the browser unresponsive on certain inputs. This tool detects that shape before running the pattern and shows an error instead. The check only covers the most common dangerous shape and cannot catch every risky pattern.
Can I replace matched text?
No. This tool focuses on pattern validation and match inspection; it does not offer a replace/substitution feature.
Will I get the same result in other languages like Python or PHP?
Not necessarily. This tool reflects JavaScript's regex engine exactly. Other languages may differ in syntax or behavior (for example, named group syntax or support for lookbehind).
Related tools
- Cron Expression Generator | GUI Builder & Next Run TimeBuild a cron expression from five fields or by editing it directly, validate the syntax instantly, and see the next 5 run times. Runs entirely in your browser — nothing is sent to a server.
- Hash Generator — MD5, SHA-1, SHA-256, SHA-384, SHA-512Compute MD5, SHA-1, SHA-256, SHA-384, and SHA-512 hashes from text or a file, all at once. Useful for verifying file integrity or checksums. Everything runs in your browser — your text and files are never sent anywhere.
- JSON Formatter & Validator | Minify, Beautify, and Detect Syntax ErrorsFormat JSON with 2/4-space or tab indentation, or minify it, and see syntax errors with the exact line and column where they occur. Everything runs in your browser only — your JSON is never sent anywhere.
- Password Generator — Custom Rules & Strength MeterGenerate secure random passwords with a chosen length and character types (uppercase/lowercase/digits/symbols), 1 to 20 at once, with an entropy (bit) score and strength label. Everything runs in your browser using crypto.getRandomValues() — nothing is ever sent anywhere.
- All tools