Find and Replace

How to use 3 steps
  1. Paste your Text.
  2. Enter what to Find and what to Replace with, and pick the Mode.
  3. Tick Case-sensitive or Whole words only if needed, then press Replace and Copy.
Literal text, or a pattern in regex mode.
Use $1, $2 for capture groups in regex mode.
Result

How this tool works

Both modes end up as a regular expression. In literal mode every character you type is escaped first, so a full stop matches a full stop and nothing else, and the replacement text is escaped too — a dollar sign stays a dollar sign rather than being read as a group reference. In regex mode your pattern is compiled as written, which gives you groups, alternation and character classes, and gives you the chance to write something invalid.

Matching is case-insensitive unless you tick the box. Scope decides whether every occurrence is replaced or only the first. The whole-word option wraps your text in word boundaries and applies to literal mode only, because in regex mode you are already able to write boundaries yourself. If the pattern does not compile, the error from the regular expression engine is shown rather than a generic failure.

Reading the result and avoiding the traps

  • Two numbers are reported, and they differ on purpose: the first is how many times the text occurs anywhere in the input, the second is how many were actually changed. Replacing only the first occurrence of six matches reports six and one.
  • Whole word uses word boundaries, not spaces: a boundary sits between a letter or digit and anything else, so hyphenated and apostrophised words split at the punctuation, and an underscore counts as part of the word.
  • Dollar signs are safe in literal mode: prices and variable names are replaced exactly as typed. In regex mode the same text is a group reference, so use it deliberately or escape it.
  • The original is never modified: the input stays where it is and the result is shown separately, so an over-eager pattern costs you nothing but another run.

Case-insensitive by default

Worth knowing before your first run, because it is the setting most likely to produce a surprise.

Searching for cat matches Cat and CAT as well, and replaces all of them with exactly what you typed. So replacing cat with dog turns a sentence-opening Cat into a lowercase dog.

The [msm_tool slug="find-and-replace"] has a case-sensitive option, and for anything where capitalisation carries meaning — names, code identifiers, sentence starts — it is the one you want.

Whole words, and why partial matches bite

Without whole-word matching, a search for cat also matches the middle of concatenate, category and indicated. Replacing it produces condogenate, which is the classic demonstration and happens constantly in practice.

The rule: if you are replacing a word, match whole words. If you are replacing a fragment — a URL, a prefix, a file extension — you cannot, and you should read the preview more carefully.

Order matters when you make several replacements

Replacements are applied in sequence, and each one runs on the result of the last. That creates a specific trap:

Replace A with B, then B with C, and everything that was originally A is now C. You wanted two separate substitutions and got a chain.

The fix is to route through a placeholder that appears nowhere in the text — replace A with a unique marker, then B with C, then the marker with B. Awkward, and reliable.

The same applies to swapping two values. There is no way to do it in two steps without the intermediate collision.

Check the count before you commit

The number of replacements is the single most useful thing to look at. If you expected three and it reports forty-seven, stop — something is matching that you did not intend, and it is almost always a partial match or a case difference.

A count of zero is equally informative. It usually means a typo in the search term, a trailing space, or a character that looks like the one you typed and is not — a curly quote where you typed a straight one, or a non-breaking space where you typed a normal one.

Quotes and dashes that look identical

Text from a word processor or a website carries typographic characters: curly quotes, en dashes, ellipsis characters. They look like their plain equivalents and are different code points.

Searching for "quoted" with straight quotes will not find “quoted” with curly ones. This is behind a large share of the searches that mysteriously find nothing, and the fix is to copy the search term out of the text itself rather than typing it.

Where this is the right tool

  • Changing a name, a term or a URL consistently through a document.
  • Cleaning up a placeholder left in a template.
  • Converting a delimiter — commas to tabs, semicolons to newlines.
  • Stripping a repeated prefix or suffix from a list of lines.

Where it is not

Anything requiring judgement about context. Replacing a word only when it appears as a noun, or only outside quotation marks, or only in some sections, is not a find-and-replace job — and attempting it with a clever search term is how documents get quietly corrupted.

Keep the original. Everything happens in your browser, so nothing is uploaded, but nothing is undoable either.

Frequently Asked Questions

Specific to the Find and Replace. Broader questions about this category are answered on the category page.

Yes, in regex mode: bracket part of the pattern and refer to it with a dollar sign and its number. Literal mode treats a dollar sign as text.
It is applied to literal searches only. Add the boundary markers to your own pattern instead, which also lets you put them on one side.
Scope was set to the first occurrence. The count tells you how many are there so you can decide whether to run it across all of them.
Nothing is replaced and the message from the engine is shown, which usually names the position of the problem — an unclosed bracket or a stray quantifier.
No. The input is left alone and the result appears separately, so you can adjust the pattern and run it again from the same starting point.

Subscribe to receive notifications about new tools, features, and productivity tips.