Find & replace
Regex find and replace
Rewrite text with a pattern and a replacement, and check every change, highlighted, before you copy the result.
$3group 3
3 replacements
/posts/regex-tips/ /posts/naming-things/ /about.html /posts/hello-world/ /blog/drafts/unfinished.html
How replacement works
The tool runs JavaScript’s String.prototype.replace in a worker and shows each replaced span with an ochre underline, so you can check the edits before copying. Without the g flag only the first match is replaced; with Each line separately, the first match of every line.
These tokens insert parts of the match into the replacement:
$1…$99: the text of a numbered group ($10falls back to$1followed by 0 if there is no group 10).$<name>: a named group;$&: the whole match.$`and$': the text before and after the match;$$: a literal dollar sign.
Paste text, type it, or open or drop a text file onto the input; it is read in your browser and never uploaded. Line mode suits lists of paths, log lines and CSV rows: anchors work per line even without the m flag, and a pattern without g still edits every line once.
Questions
Why does only the first match change?
The g flag is off. Turn it on to replace every match, or choose “Each line separately” to replace the first match on every line.
How do I insert a literal dollar sign?
Write $$. A $ that is not followed by a valid token (for example $x) is kept as it is.
Is there a size limit?
No fixed limit; it runs in your browser. Very large texts are slower to highlight, and a replacement that takes more than two seconds is stopped.