Matches, groups and replacement at once
Shows every match and its position, the capture groups, and the result of a replacement.
A regular expression is almost never right first time. Debugging is a loop of tweak-and-look, and it goes faster when matches and capture groups are visible side by side.
The replacement field removes the second half of the work. References like $1 and $2 substitute the groups, so reordering an ISO date into a human one takes one line and the result appears immediately.
What this calculator shows
- Every match with its position in the text
- The capture groups for each match
- The text after replacement, with group substitution
What to keep in mind
- The syntax is JavaScript's — the same flags and quirks as in a browser or Node.
- The g flag is added automatically, otherwise iterating matches would loop on the first one.
FAQs
What do the g, i and m flags do?
g finds every match rather than the first; i ignores case; m makes ^ and $ apply per line rather than to the whole text.
How do I reference capture groups?
As $1, $2 and so on in bracket order. Named groups written (?<name>...) are referenced as $<name>.
Why does my pattern match too much?
Most likely greedy quantifiers: .* takes as much as it can. Add a question mark — .*? — to make them lazy.
Do regular expressions behave the same everywhere?
No. PCRE, Python and JavaScript differ on lookbehind, named groups and Unicode properties. This uses the JavaScript flavour.
Worked example
Reordering a date
Input: (\d{4})-(\d{2})-(\d{2}) replaced with $3.$2.$1
Output: 2026-08-01 becomes 01.08.2026
Note: Three capture groups — year, month, day — reversed in the replacement. It is the most common practical use of regular expressions there is.