Find and Replace Text

Replace every occurrence of a word or pattern in your text, with case sensitivity, whole-word matching and full regular expression support.

4(function(){return "Matches";})()
69Characters

Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.

What the Find and Replace Text tool does

This find and replace text tool will replace every occurrence of a word or pattern in your text, with case sensitivity, whole-word matching and full regular expression support. Paste your text in, pick the options you need, and copy the result straight back out. It is most often used for swapping a product or person's name throughout a document. Next to this one sits our add prefix and suffix to lines tool.

How to use it

  1. Paste your text.
  2. Enter what to find and what to replace it with.
  3. Turn on "whole words only" to avoid matching inside longer words.
  4. Copy the result, or download it as a file.

How it works

By default the search text is treated literally, so characters like . and ? match themselves rather than acting as regular-expression operators. That is what most people expect.

"Whole words only" wraps the search in word boundaries, which is the fix for the classic problem of replacing "cat" and accidentally changing "concatenate" and "catalogue" as well. The match counter above shows how many replacements will be made, so you can check before copying.

Regular expression mode gives you full pattern matching and capture groups: use $1, $2 in the replacement field to reference captured groups. An invalid pattern leaves the text untouched and shows "invalid" in the match counter rather than throwing an error.

When to use it

  • Swapping a product or person's name throughout a document.
  • Normalising inconsistent terminology across a long text.
  • Reformatting data with a regular expression and capture groups.

Common mistakes to avoid

  • Forgetting "whole words only" and changing substrings inside unrelated words.
  • Leaving case matching off when replacing a name, so "Mark" and "mark" are both changed.
  • Writing a regex with an unescaped special character and wondering why nothing matches.

Frequently asked questions

How do I use capture groups?

Turn on regex mode, wrap part of your pattern in parentheses, and reference it in the replacement as $1 for the first group, $2 for the second, and so on. For example, find (\w+)@(\w+) and replace with $2 at $1.

Why did it change words I did not intend?

Almost always because "whole words only" was off, so the search matched inside longer words. Turn it on and check the match counter before copying.

Related tools

See all text & writing tools →