How to use the Regex Tester
- Enter your pattern between the slashes, without the surrounding
/. - Toggle flags such as
g (all matches), i (ignore case) and m (multiline). - Paste your test text. Matches are highlighted on the right and listed with their index and capture groups below.
- Tick Replace and enter a replacement like
$1 or $<name> to preview String.replace. - Pick a pattern from the Pattern library to start from a tested email, URL, IP or date regex.
JavaScript regular expressions
This tester uses your browser's own RegExp engine, so results are exactly what String.match, matchAll, replace and RegExp.exec return in JavaScript and Node.js. That includes modern syntax: named groups (?<name>…), lookbehind (?<=…), Unicode property escapes like \p{L} with the u flag, and match indices with the d flag.
What the flags do
| Flag | Name | Effect |
g | global | Find every match instead of stopping at the first. |
i | ignoreCase | Letters match regardless of case. |
m | multiline | ^ and $ match at the start and end of each line. |
s | dotAll | . also matches line breaks. |
u | unicode | Treat the pattern as code points; enables \p{…} and \u{…}. |
y | sticky | Only match at the current lastIndex position. |
d | hasIndices | Report start and end positions for each capture group. |
Catastrophic backtracking protection
Patterns with nested quantifiers, such as (a+)+$ or (\w|\d)*x, can take exponential time on inputs that almost match. In a normal web page that freezes the tab. Here every match runs in a background Web Worker that is stopped after one second, and you get a clear warning instead of a hung browser. The same pattern in production code could be a ReDoS vulnerability, so treat the warning as a bug to fix.
Tips for writing better regexes
- Anchor patterns with
^ and $ when validating whole values, otherwise a match anywhere in the string passes.
- Prefer specific classes like
[^"]* over .*; they are faster and avoid over-matching.
- Use non-capturing groups
(?:…) when you do not need the captured value.
- Name your groups.
match.groups.year is easier to read than match[1].
Frequently asked questions
Which regex flavor does this tester use?
JavaScript (ECMAScript), via your browser’s built-in RegExp. Most syntax is shared with PCRE, Python and Java, but features such as possessive quantifiers, atomic groups and inline modifiers like (?i) are not available in JavaScript.
Why does my pattern only find one match?
Without the g (global) flag, JavaScript stops after the first match. Enable g to find every occurrence.
How do I reference groups in the replacement?
Use $1, $2… for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign.
Why did the tester stop with a timeout?
The pattern took more than one second on your input, which almost always means catastrophic backtracking. Look for nested quantifiers like (x+)+ or overlapping alternatives like (a|a)* and rewrite them so each character can only be matched one way.
Is my test data sent anywhere?
No. Matching runs locally in a Web Worker inside your browser. Your pattern and text are only stored in your own browser so they are still there when you come back.