Find & Replace with Regex
Run powerful find-and-replace over a whole block of text — literal or full regex with flags, capture-group references, a live highlighted preview, and a match count.
Interactive Client Prototype Sandbox
The quick brown fox jumps over the lazy dog. The dog was not amused. The End.
Disclaimer: This free tool is provided “as is,” without warranties of any kind, and is for general informational purposes only — not professional, legal, financial, medical, tax, or engineering advice. Results may contain errors; verify anything important independently and use at your own risk. We accept no liability for any loss or damage arising from its use. See our Terms of Use for details.
Step-by-Step Guide
Enter your search pattern in the Find field and your replacement in the Replace field. Toggle Regex mode to use a full regular expression instead of a literal string. When Regex is on, also toggle flags as needed: g (global — replace all occurrences), i (case-insensitive), m (multiline — ^ and $ match line starts/ends), and s (dotAll — . matches newlines). The live preview highlights every match in the text as you type; matched text turns orange and the match count is shown.
Click Apply to rewrite the entire text with all replacements made and display the result below. Click Copy Result to copy the replaced text to clipboard. Invalid regex patterns show an inline error message rather than silently failing.
Using capture groups in replacements
In Regex mode, you can use $1, $2, etc. in the replacement string to reference captured groups from the pattern. For example, find pattern (\w+)@(\w+) and replacement [$2/$1] transforms 'user@example' into '[example/user]'. This makes Find & Replace powerful for reformatting structured text like CSV columns, date formats, or code identifiers.
Literal find: find 'color', replace 'colour' (case-insensitive, global) — replaces every instance regardless of capitalization. Regex find: pattern (\d{4})-(\d{2})-(\d{2}), replacement $2/$3/$1 — transforms every ISO date like '2024-03-15' into US format '03/15/2024' across the entire text in one pass. Capture group example: find (\w+)og, replace [$1OG] — 'dog' → '[dOG]', 'log' → '[lOG]', 'fog' → '[fOG]'.
Who it's for
Writers, developers, data cleaners, and anyone reformatting large blocks of text.
Core Features
- Literal or regular-expression matching with g / i / m / s flags.
- Capture-group references ($1, $2) in the replacement string.
- Live highlighted preview of every match and a running match count.
- Apply to rewrite the text, or copy the result; invalid patterns show an inline error.
🛡️ No tracking — your inputs, keys, and details never leave this client sandbox.
What is the difference between literal and regex mode?
In literal mode, the find string is treated as exact text to match — special characters like . * + ? ( ) [ ] { } | ^ $ \ are all treated as literal characters. In regex mode, those characters have special meaning as regex metacharacters. Use literal mode for simple word or phrase replacements; use regex mode when you need patterns, wildcards, or capture groups.
How do I replace text only in specific lines or contexts?
Use the multiline flag (m) with anchors ^ and $ to restrict matches to the start or end of lines. For example, find ^name: (\w+) with the m flag to match lines that start with 'name:' and capture the value. You can also use a more specific literal pattern — include unique surrounding characters in your find pattern to avoid matching the same text elsewhere in the document.
What are capture groups and backreferences?
In regex mode, parentheses in the find pattern create capture groups: text matched inside (...) is captured and numbered from left to right starting at $1. In the replacement string, $1, $2, etc. insert the captured text. For example, find (\w+) (\w+), replace $2 $1 swaps every pair of adjacent words. Two more replacement codes exist beyond numbered groups: a dollar sign immediately followed by an ampersand inserts the entire matched text, and two dollar signs in a row insert one literal dollar sign.
Can I undo a replacement?
The Apply button rewrites the text in the output area — it does not modify the original input. You can still see and copy the original from the input field. If you want to chain replacements, copy the result, paste it as new input, and run another replacement pass.
Three things about regex find-and-replace that trip up most users
Find-and-replace sounds like one of the simplest operations in text editing. In practice, three misunderstandings cause the vast majority of failed or partial replacements — and clearing them up turns a frustrating tool into an indispensable one.
Myth vs. reality: the special-characters problem
Myth: you can type any search string and it will match literally. Reality: in regex mode, characters like ''. Most confusion about "why didn't my regex match?" traces back to this — either forgetting to escape a literal character, or accidentally treating a plain string as a pattern.
Myth vs. reality: stacked replacements don't chain automatically
Myth: you can run one replacement and it will handle all your cases. Reality: each pass of find-and-replace operates on a fixed input. If you need to normalize curly quotes to straight quotes AND then strip trailing spaces, you need two separate operations. The output of one can become the input of the next by copying and pasting into a new run, or by chaining via Apply → copy result → paste as new input. A single regex can sometimes do both steps at once using alternation ('') across an entire document in one pass — a transformation that would require a spreadsheet formula or a script to do any other way. Once you internalize capture groups, you stop thinking of find-and-replace as a word-swap tool and start using it as a structural reformatter.