Regex Tester
Build a JavaScript regular expression and watch it match your text in real time. Highlight every match, inspect capture groups, and preview replacements — all in your browser.
Matches
Group breakdown
What a regex tester is for
Regular expressions are dense and easy to get subtly wrong. A tester
gives you a tight feedback loop: tweak the pattern, see instantly which
parts of your text it matches and which it misses. That beats sprinkling
console.log through code or guessing why a validation
rejects a valid input.
The flags
-
g— global. Find all matches, not just the first. -
i— ignore case. Match upper- and lower-case alike. -
m— multiline. ^ and $ match at line breaks. -
s— dotall. . also matches newline characters. -
u— unicode. Treat the pattern as Unicode code points. -
y— sticky. Match only from lastIndex onward.
Capture groups and replacement
Wrap part of a pattern in parentheses to capture it; the matched text
shows up as Group 1, Group 2 and so on. Name a group with
(?<year>\d{4}) and it appears by name too. In
the replacement field you can reference captures with $1 or
$<year>, and the whole match with $&.
Frequently asked questions
Which regex flavour is this?
It uses your browser's built-in JavaScript (ECMAScript) regular-expression engine — the same one you'd use in Node.js or front-end code. Syntax like named groups (?<name>…), lookbehind and Unicode property escapes is supported wherever your browser supports it.
Why are only some matches highlighted?
Without the global (g) flag, a regex stops at the first match — that's standard JavaScript behaviour. Turn on the g flag to find and highlight every match in the text.
How do capture groups show up?
Each match lists its numbered groups (Group 1, Group 2, …) and any named groups you defined with (?<name>…). A group that didn't participate in the match is shown as 'undefined'.
How does replace work?
Enable 'Test a replacement' and type the replacement string. It runs String.replace with your regex, so you can use $1, $2 or $<name> to insert captured text, and $& for the whole match.
Is my text sent anywhere?
No. The pattern and test text are evaluated entirely in your browser. Nothing is uploaded, logged or stored.