How to use the Find and Replace
- Paste your text into the large box.
- Type the word or phrase to find, and what to replace it with. Every match is highlighted and counted as you type.
- Tick Match case, Whole words only or Regular expression if you need them, and switch the preview to Show result to check the outcome.
- Click Replace all. Use Undo if you change your mind, then copy or download the text.
Features
- Live match count and highlighted preview
- Preview the result before replacing anything
- Match case and whole-word options
- Regular expressions with $1 and named capture groups
- Clear error messages for invalid patterns
- Undo for the last 20 replacements
Plain searches
By default the tool finds your text exactly as typed, ignoring upper and lower case. Match case makes “Apple” and “apple” different. Whole words only stops partial matches, so replacing “cat” no longer turns “category” into “dogegory”. A word boundary is anything that is not a letter, digit or underscore, and it works for accented and non-Latin letters too.
Leave Replace with empty to delete every match, which is a quick way to strip a repeated phrase, a signature or tracking text from a document.
Regular expressions in a nutshell
Tick Regular expression to search by pattern instead of exact text. A few building blocks cover most needs:
| Pattern | Matches |
|---|---|
\d+ | One or more digits, such as 7 or 2026 |
\s+ | A run of spaces, tabs or line breaks |
. | Any single character except a line break |
colou?r | color or colour (the u is optional) |
[aeiou] | Any one vowel |
^ and $ | The start and end of each line |
\p{L}+ | A word in any alphabet |
Characters such as . * + ? ( ) [ ] { } ^ $ | \ have special meanings in patterns. Put a backslash before one to match it literally, or untick Regular expression to search for plain text.
Using capture groups
Parentheses capture part of a match so you can reuse it in the replacement as $1, $2 and so on. Some practical examples:
- Swap names: find
(\w+), (\w+)and replace with$2 $1to turn “Lovelace, Ada” into “Ada Lovelace”. - Reformat dates: find
(\d{4})-(\d{2})-(\d{2})and replace with$3/$2/$1to turn 2026-03-14 into 14/03/2026. - Wrap every number: find
\d+and replace with[$&], where$&stands for the whole match. - Join lines: find
\nand replace with a space; type\nin the replacement to insert a line break instead.
Named groups work too: (?<year>\d{4}) can be reused as $<year>. Patterns run in your browser’s JavaScript engine with multiline and Unicode modes on, so ^ and $ match at every line and Unicode classes such as \p{L} are available. To build and debug a complicated pattern step by step, try the Regex Tester.
Avoiding mistakes
- Switch the preview to Show result before you click Replace all. It shows each replacement in place.
- Check the match count. If it is far higher than you expected, the pattern is too broad.
- Replace longer phrases before shorter ones they contain, or the short replacement will break the long phrase first.
- Keep the original handy, or compare before and after with Text Compare.
Frequently asked questions
How do I replace a word without changing longer words that contain it?
Tick “Whole words only”. The tool then matches the word only when it is not part of a longer word, so “cat” no longer matches inside “category”.
How do I use $1 in the replacement?
Tick “Regular expression” and put parentheses around the part of the pattern you want to keep. The first group becomes $1, the second $2, and $& inserts the whole match.
How do I replace line breaks?
Tick “Regular expression”, type \n in the Find box and put a space or any separator in Replace with. For more line-break options, use the Remove Line Breaks tool.
Why do I see “Invalid regular expression”?
The pattern has a syntax error, such as an unclosed bracket or a stray special character. Fix the pattern, or untick “Regular expression” to search for the text literally.
Can I undo a replacement?
Yes. Undo restores the text as it was before the last Replace all, and you can step back through up to 20 replacements.