Text & Code
Regex Tester
Test JavaScript regular expressions with live match highlighting, capture groups, named groups, match positions, and replacement preview.
Character classes
. Any char (except newline)\w Word char [a-zA-Z0-9_]\d Digit [0-9]\s Whitespace\W \D \S Negations[abc] Character set[^abc] Negated set[a-z] RangeQuantifiers
* 0 or more+ 1 or more? 0 or 1{n} Exactly n{n,} n or more{n,m} Between n and m*? +? ?? Lazy (non-greedy)Groups & anchors
(abc) Capture group(?<name>abc) Named group(?:abc) Non-capture group(?=abc) Lookahead(?!abc) Neg. lookahead(?<=abc) Lookbehind^ $ Start / end\b \B Word boundaryFlags
g Global (all matches)i Case-insensitivem Multiline (^ $ per line)s DotAll (. matches \n)u Unicode modev Unicode sets (ES2024)d Indices (hasIndices)Quick examples
About JavaScript RegExp & Dialects
What it does
The Regex Tester evaluates a JavaScript regular expression against sample text and shows all matches highlighted inline. Each match is listed with its position, full value, numbered capture groups, and named capture groups. The replacement tab previews how String.prototype.replace() would transform the input. All processing happens in your browser using the native ECMAScript RegExp engine.
How it works
Patterns are compiled with new RegExp(pattern, flags). Matches are found using re.exec() in a loop. A guard of 5000 iterations prevents infinite loops on zero-length matches. Named groups are exposed via the match.groups object (requires the d flag or modern browsers).
Common mistakes & Dialect Differences
- PCRE vs ECMAScript: JavaScript uses the ECMAScript standard. PCRE syntax like possessive quantifiers (
a++), atomic grouping ((?>...)), and branch reset groups ((?|...)) are unsupported in JavaScript. - Missing global flag: Without
g, only the first match is returned. - Backslash escaping: In the pattern input field, enter
\dnot\\d— the tool handles no double-escaping.
Limitations
- ReDoS (catastrophic backtracking) on pathological patterns can hang the browser tab. The tool sets a match-count guard but cannot interrupt native regex execution.
- Lookbehind assertions require Chrome 62+, Firefox 78+, Safari 16.4+.
- The
vflag (Unicode sets) requires Chrome 112+, Firefox 116+, Safari 17+.