Regex replace preview

Enter some text, a regular expression and a replacement: matches are highlighted live in the original text and the replacement result updates instantly, with no button to click.

Example:

How it works

Each time you change the text, the pattern or the replacement, the tool recompiles the regular expression, finds all matches to highlight them directly in the original text, then applies the replacement to show the final result — handy for tweaking your pattern until you get exactly the output you want.

How do I reference captured groups in the replacement?

Use $1, $2, etc. to insert the content of the first, second capturing group, and so on, exactly as with String.prototype.replace in JavaScript. A named group (?<day>...) can be referenced with $<day>.

Why does the highlighting show more matches than the replacement?

The highlighting always forces the "g" flag so that every occurrence is shown visually, whereas the replacement respects exactly the flags you entered: without the "g" flag, only the first replacement is made even if several matches are highlighted.

No data is sent to a server: the text, the pattern and the result stay entirely in your browser.