Regex Replace Tester (Live, with Capture Groups)
Live-preview regex find + replace. Type a pattern, type a replacement (with $1, $&, etc. for backreferences), see the result instantly. All JavaScript regex flags (g, i, m, s, u, y) supported. Useful for working out a substitution before committing it to code or running it through a CLI.
Replacement reference
$1,$2, … — Nth captured group$&— entire match$`— text before the match$\'— text after the match$<name>— named capture group$$— literal dollar sign
How to use the Regex Replace Tester (Live, with Capture Groups)
Type a regex pattern and a replacement template. The output updates as you type. Capture groups in the pattern (parentheses) can be referenced in the replacement with $1, $2, etc. Named groups ((?<year>\d{4})) can be referenced with $<year>.
The flag checkboxes control how the regex is compiled: g for replace-all (off = replace first match), i for case-insensitive, m for multiline (^/$ match line boundaries), s for dotall (. matches newlines), u for full Unicode support.
About Regex Replace Tester (Live, with Capture Groups)
Regex find-and-replace is one of the most powerful text manipulation primitives. It's essential when refactoring code (rename a function in every file), processing logs (extract structured data from unstructured lines), or scrubbing data (remove personal information from samples). The hard part is getting the pattern and replacement right — small mistakes either match too much or escape your control character. A live tester catches both kinds of error before you run the substitution on real data.
This tool uses JavaScript's regex engine, which is close to but not identical to PCRE (the most common other flavour). Differences: JS has no possessive quantifiers, no recursion, no lookahead/lookbehind limit (PCRE had a 254-char limit, JS doesn't). For most patterns, what works here will work in jq, sed (with -E), grep -E, Python re, and most language standard libraries.
Common use cases
- Code refactoring — preview a rename or signature change before applying to your codebase.
- Log scrubbing — confirm a pattern removes emails / IPs / tokens before running on production logs.
- Data cleanup — fix delimiter inconsistencies in CSV / TSV files.
- Format conversion — quick one-off transformations (e.g., 2026-01-15 → 15/01/2026).
Frequently asked questions
Why is my $1 not working?
(foo) not foo.How do I replace a literal dollar sign?
$$ in the replacement.