Regex Replace
Write a pattern and a replacement — using $1, $<name>, and other backreferences — to transform text. Runs entirely in your browser; nothing you type is ever sent anywhere.
Quick Learn
Find-and-replace with a regex works like ordinary find-and-replace, except the "find" side is a pattern instead of literal text, and the "replace" side can reference pieces the pattern captured. $1 inserts whatever the first group matched, $<name> inserts a named group by name, and $& inserts the entire match — so a single replacement can rearrange, reformat, or partially rewrite text based on what it actually found, not just swap one fixed string for another.
This tool runs JavaScript's own String.replace() under the hood, so the replacement syntax here is exactly what you'd use in real code: $1, $2, $<name>, $&, and $$ for a literal dollar sign. Turn on the g flag to replace every match instead of just the first — the same distinction that matters for the Regex Tester tool. Everything runs locally in your browser.
Best Practices
- •Forgetting the g (global) flag is the most common reason a replace "doesn't work" — without it, only the first match in the whole string gets replaced.
- •Named groups make a replacement self-documenting: $<year>/$<month> reads far better months later than $1/$2, especially once a pattern has three or more groups.
- •$$ inserts a literal dollar sign — necessary if your replacement text should actually contain a $ character, since a bare $ followed by certain characters is otherwise interpreted as a backreference.
- •Check the highlighted "Original" preview before trusting the result on real data — it shows exactly which spans will be replaced, which catches an overly broad pattern before it rewrites more than intended.
More Regex Tools
Regex Tester
Test a pattern against sample text with live match highlighting and capture groups.
Regex Explainer
Break down a regex pattern into plain-English tokens.
Common Patterns Library
Copy-ready regex patterns for email, URL, IPv4, and more.
Frequently Asked Questions
Want the engineering deep-dives behind tools like this one?