About the Regex Tester
This regex tester checks JavaScript regular expressions against your text with instant highlighting. See every match, capture group and position, try replacements, get a plain-English breakdown of the pattern, and stay safe from patterns that would freeze the page.
How to test a regular expression
- Type a pattern (without the surrounding slashes) and pick flags like
gori. - Paste text to search. Matches are highlighted instantly.
- Open Match list for positions and capture groups, or Explain for a breakdown of the pattern.
- Tick Replace with to test replacements using
$1or$<name>.
JavaScript regex, exactly
Patterns run on your browser's own regex engine, the same one used by JavaScript and Node.js, so what matches here matches in your code.
Protection from runaway patterns
Some patterns, like (a+)+$, can take forever on certain input (“catastrophic backtracking”). Each test runs in a background thread and is stopped after one second, with a warning, so the page never freezes.
Questions
Which regex flavour is this?
JavaScript (ECMAScript). It supports lookahead and lookbehind, named groups (?<name>…), Unicode property escapes \p{L} with the u flag, and the s (dotAll) flag.
How do I reference groups in a replacement?
Use $1, $2 for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign.
Is my text uploaded?
No. Everything runs in your browser.