Regex Tester
Test JavaScript regular expressions with live match highlights, capture groups, and replace preview.
Matches in text
Capture groups
| # | Offset | Match | Group |
|---|---|---|---|
|
—
|
Replace preview
Quick reference
\d
Digit (0–9)
\w
Word char (a-z, 0-9, _)
\s
Whitespace
[^abc]
Anything except a/b/c
^/$
Start / end of line (with m flag)
a*
Zero or more
a+
One or more
a?
Zero or one
a{n,m}
Between n and m repetitions
(?<name>…)
Named capture group
(?=…)
Lookahead
(?<=…)
Lookbehind
About this tool
Regex Tester evaluates JavaScript regular expressions against a body of test text and highlights every match in place. The pattern field accepts the full ECMAScript regex syntax — anchors, character classes, alternation, lookahead, lookbehind, named capture groups, Unicode property escapes — with separate toggles for the standard flags (g global, i ignore case, m multiline, s dot-matches-newline, u Unicode, y sticky). Matches are colour-coded and capture groups are listed below the highlight for each one.
Beyond matching, the tool can run a replace preview side-by-side with the original — type the replacement string (with $1 / $<name> backreferences) and see exactly what your regex will produce against the test input. Every operation runs in your browser with the native RegExp engine, so what you debug here is exactly what executes in production JavaScript (Node, Bun, Deno, every browser).
When to use this tool
- Building input validators. Email, phone-number, postcode patterns — design and verify with realistic test data before pushing to code.
- Parsing log files. Iterate a multi-group capture pattern against real log lines until every field comes out clean.
- Bulk editing. Test a find/replace pattern before running it across hundreds of files in your editor.
- Learning regex. Highlighted matches plus instant feedback is the fastest way to internalise look-around, anchors, and backreferences.
About regex flavours
This tool uses JavaScript regex (ECMAScript 2018+). PCRE, Python, .NET, Go, and Java all differ slightly — PCRE supports recursive patterns JavaScript does not, Python'sre module lacks lookbehind in some versions, Go uses RE2 which forbids backreferences entirely. If you are targeting a non-JS environment, double-check the flavour-specific features at the receiving end. For pure ECMAScript-compatible patterns this tool is authoritative.
Frequently asked questions
What is the difference between g, m, and s flags?
g (global) makes .match() and .replace() find every match instead of just the first. m (multiline) makes ^ and $ match at line breaks within the input, not just at the start/end of the whole string. s (dotall) makes . match newlines too (default behaviour is to skip them). They are independent — combine as needed.
Why does my lookbehind not work?
(?<=...) requires modern ECMAScript (2018+) and is available in all current evergreen browsers and Node 10+. Older runtimes (IE 11, Safari before 16.4, very old Node) reject the pattern at compile time. Our tester uses the browser's engine so if your tester works but the target runtime fails, the target is too old. Workaround: rewrite without lookbehind using a non-capturing group and a slice.
How do I test against a long string?
What is "catastrophic backtracking"?
(a+)+ against a long string ending in a non-match. The regex engine tries every permutation before giving up. Modern JavaScript engines do not have a timeout, so the page can hang. Fix: rewrite without nested quantifiers, use possessive groups via (?:a+), or anchor the pattern more strictly.