Regex Replace Tester
Enter a regular expression, replacement string, and sample text. See the replace result. Uses JavaScript replace (global flag).
Test replace
How it works
We create a RegExp with the g flag, then use String.prototype.replace(). $1, $2 in replacement refer to capture groups.
When to use it
Use when writing or debugging replace patterns (e.g. for search-and-replace).
Frequently asked questions
Replace all?
We use the g flag so all matches are replaced.