Regex Tester
Test JavaScript regular expressions live — highlighted matches, capture groups, replace preview and a cheat sheet
How it works
Type a pattern and toggle flags (g, i, m, s, u, v, y, d); the test text is matched as you type using your browser's own JavaScript regular-expression engine, so results are exactly what new RegExp(pattern, flags) gives in JavaScript and Node. Matches are highlighted in place in the editor, and the list on the right shows each match with its position and every capture group — numbered ($1, $2 …) and named ($<year>) — with undefined groups shown as such and, with the d flag, the exact span of each group. Enter a replacement to preview text.replace(regex, replacement) with all the usual tokens ($1, $<name>, $&, $`, $'). Matching runs in a Web Worker with a time limit, so a pattern that backtracks catastrophically is stopped and explained instead of freezing the tab. The pattern and flags live in the URL; Share also carries the test text and replacement, compressed.
Questions
Which regex flavour is this?
JavaScript (ECMAScript), as implemented by your browser — the same engine used by new RegExp() and String.prototype.match/replace. It supports lookbehind, named groups, Unicode property escapes (\p{…} with u or v), the v flag's set operations and the d flag for group indices.
What do the flags mean?
g finds every match instead of the first; i ignores case; m makes ^ and $ match at line boundaries; s lets . match newlines; u enables full Unicode; v is Unicode-sets mode (a superset of u with class set operations); y is sticky (match only at the start here); d records the start and end of each capture group.
Why did my pattern time out?
Nested or overlapping quantifiers like (a+)+ or (\w*\s?)* can make the engine try an exponential number of paths — catastrophic backtracking. The tester stops it after 2.5 seconds. Anchor the pattern, make quantifiers possessive-like by using more specific classes, or avoid nesting quantifiers.
How do I use groups in the replacement?
$1, $2 … for numbered groups, $<name> for named ones, $& for the whole match, $` and $' for the text before and after it, and $$ for a literal dollar sign — exactly as String.prototype.replace works.
Can I share a test?
Yes. The pattern and flags are in the page URL as you type; Share copies a link that also includes the test text and replacement, compressed into the URL fragment.
Is my text uploaded?
No. Everything runs in your browser; nothing is sent to a server.