Test a find-and-replace with capture groups and named references, with each substitution listed so you can see what every match became.
$1 is a group, $& the whole match, $<name> a named group, $$ a literal dollar.
Waiting for a pattern
Replacement uses your browser's own engine, with the same $ sequences your code will use.
Write a pattern
The transformed text appears here, with every substitution listed below so you can see what each match became.
Regex Replace Tester runs entirely on your device — the pattern is compiled as a regular expression and never executed as code.
You’re on the Free plan. Compare plans
The replacement template is its own small language and the part people get wrong. `$1` is a group, `$&` the whole match, `$<name>` a named group, `$$` a literal dollar — and `` $` `` and `$'` are the text before and after the match, which almost nobody knows and which turn an innocent-looking `$'` into something surprising. Every part of your template is labelled as you type it.
Every substitution is listed with its position and both forms, so you can see what each match became rather than diffing two blocks of text by eye. That is the difference between checking a replacement and hoping it worked.
An out-of-range group reference is called out. `$2` in a pattern with one group is not an error in JavaScript — it stays in the output as literal text, which looks like a bug in the replacement rather than in the pattern. The tool says which it is.
Matching runs in a separate thread that can be terminated, so a pattern that would otherwise lock the tab gets stopped and explained instead. The substitution itself is applied to the matches that thread already found, rather than by running the pattern a second time — there is no second chance to hang.
The g flag is off. Without it a replace touches the first match only — that is how `String.replace` behaves, and the status line says so when it applies.
Because the pattern has fewer than two capture groups. JavaScript leaves an out-of-range reference in the output as text rather than erroring, which is why this is flagged as a warning rather than silently passed through.
It is computed with the same `$` semantics the language uses, and the test suite checks it against `String.replace` over a few hundred generated cases. Flags, group numbering and the handling of groups that did not participate all follow the runtime.
Matching runs in a worker that is terminated when it takes too long, and you get an explanation rather than a dead tab. The page stays responsive throughout.