Text & writing

How to Find and Replace Text Without Breaking Other Words

How find and replace works, why replacing 'cat' turns 'category' into 'dogegory', when to use match case and whole words only, how to delete every copy of a word, and a worked example with match counts.

5 min readUpdated

Find and replace is one of the most useful edits you can make to a block of text, and one of the easiest to get wrong. Swap a product name across a whole document, fix a misspelt surname everywhere it appears, or strip a word out entirely - it takes one step, but that step touches every match at once, including the ones you did not mean. This guide explains exactly how the Find and Replace tool searches, what its two options change, and how to check the result before you paste it anywhere. Everything runs in your browser, so the text you paste is never uploaded.

How find and replace works

Paste your text into the first box, type what you are looking for in Find, and type its replacement in Replace with. The tool scans the text from start to finish and swaps every match at the same moment, so there is no separate 'replace all' button to press - the output box updates as you type. Underneath it you will see how many matches were replaced, or 'No matches found' when the search term does not appear at all. That count is the most important number on the page: it tells you whether the edit did what you expected before you copy or download the result.

The search is literal. Characters that mean something special in regular expressions - a full stop, a dollar sign, brackets, a question mark - are treated as plain characters, so searching for "$5.00" finds exactly that price and nothing else. The replacement is literal too: typing "$10" in Replace with puts "$10" in the text rather than being read as a code. Matches are found left to right and never overlap, so searching "banana" for "ana" finds one match, not two, because the second "ana" shares its first letter with the end of the first.

By default the search ignores case and matches anywhere, even in the middle of another word. That is usually what you want for a typo fix, and almost never what you want for a word swap. Take this sentence:

"The cat sat on the mat. Cats love catnip, and the category of Cat food matters."

Search for "cat" and replace it with "dog" with both options off, and the tool reports 5 matches replaced. The result reads: "The dog sat on the mat. dogs love dognip, and the dogegory of dog food matters." Two of those five are right. "Cats" became "dogs" with a lower-case d, because the replacement is inserted exactly as you typed it whatever the case of the text it replaces. "catnip" and "category" were changed because "cat" appears inside them. This is the classic find-and-replace accident, and it is why the match count matters: if you expected two changes and see five, stop and look.

Whole words only

Turn on 'Whole words only' and a match must stand on its own, with no letter, digit or underscore directly before or after it. Run the same example again and the count drops to 2: "The dog sat on the mat. Cats love catnip, and the category of Cat food matters." Both standalone cats - "cat" and "Cat" - were replaced, and "Cats", "catnip" and "category" were left alone because the search term is only part of each word. Punctuation counts as a boundary, so a word followed by a comma or a full stop still matches.

One limit to know: the word boundary is defined by the English letters A to Z, digits and the underscore. A search term that starts or ends with anything else - "C++", "café", a word in Hindi or Greek - will find no matches with whole words switched on, because the tool cannot see a word edge next to those characters. For terms like that, leave the option off and check the match count instead.

Match case

Turn on 'Match case' and capital letters must match exactly. With both options on, the example finds just 1 match - the lower-case "cat" at the start - and leaves "Cat food" untouched. Use it when the capital carries meaning: replacing the name "Will" without touching the verb "will", changing a brand written as "Apple" while leaving the fruit alone, or fixing an acronym like "US" without hitting "us" in every sentence. Leave it off when you want every spelling caught - but remember that the replacement keeps its own capitalisation, so a match at the start of a sentence may need a capital fixed by hand afterwards.

Deleting a word everywhere

To remove text rather than replace it, leave Replace with empty. Every match is deleted. This is handy for stripping a repeated label like "[DRAFT]", removing a tracking code pasted into every line, or deleting a filler word. Watch the spaces either side: deleting "very" from "a very good idea" leaves "a good idea" with two spaces. Search for "very " with its trailing space instead, or tidy the result afterwards with the Whitespace Remover, which collapses doubled spaces in one pass.

What it does not do

  • It does not search across line breaks - the Find box is a single line. To join lines first, use Remove Line Breaks.
  • It does not use regular expressions or wildcards; every character is matched literally.
  • It does not preserve the case of each match; the replacement is inserted exactly as typed.
  • It replaces every match at once rather than one at a time, so check the count before you copy the output.

A safe workflow for big replacements

  1. Paste the full text and type the search term with Replace with still empty - the count tells you how many matches exist before anything changes in your source.
  2. Decide whether the number is right. If it is higher than expected, turn on whole words only; if capitals matter, turn on match case.
  3. Type the replacement and read the output, paying attention to sentence starts and to words the term sits inside.
  4. Copy the result or download it as a .txt file, and keep the original until you have checked it.

For several different swaps, run them one after another: copy the output back into the text box and change the search term. Do the longest phrase first, so replacing "New York City" happens before a shorter replacement for "York" can change it. When you are ready, open Find and Replace and try the cat sentence above to see the three match counts for yourself.

Frequently asked questions

Why did find and replace change parts of other words?
Because a plain search matches the term anywhere, including inside longer words, so replacing "cat" also changes "category" and "catnip". Turn on 'Whole words only' and a match must have no letter, digit or underscore directly beside it, which leaves those words alone. The match count under the box is the quickest way to spot this: if it is higher than the number of changes you expected, check the output before copying it.
How do I remove a word from text everywhere?
Type the word in Find and leave Replace with empty - every match is deleted. Include the space after the word in your search ("very " rather than "very") so you are not left with double spaces, or clean them up afterwards with a whitespace remover. Turn on whole words only if the word could also appear inside longer words.
Does find and replace support regular expressions?
No. This tool matches text literally, so dots, dollar signs, brackets and question marks are searched for as ordinary characters and the replacement is inserted exactly as typed. That makes it safe for prices, file paths and code snippets, which a regular-expression search would misread. It also means wildcards are not available, and the Find box cannot match a line break.