Find and Replace Text

Search your text for a word, phrase or pattern and replace every match at once. Use plain text for literal searches, or switch to regular expressions for patterns with capture groups. The match count, a highlighted preview and the finished result all update while you type.

Text Cleanup Runs in your browser

Find and Replace in Your Text

In regex mode you can use $1, $2 and $& in the replacement.

How to Use the Find and Replace

  1. Paste your text, then enter what to Find and what to Replace with.
  2. Choose plain text or a regular expression, and set options such as Match case or Whole words only.
  3. Check the match count and the highlighted preview, then copy or download the Result.
  4. Leave the replacement empty to delete every match.

About This Tool

Writers cleaning up repeated terms, developers refactoring snippets and logs, and analysts fixing formats in pasted data.

Input: Plain text  ·  Output: Replaced text.

Features and Limitations

Features

  • Plain mode treats characters like ( . * ? as ordinary text, so nothing needs escaping.
  • Regex mode supports capture groups ($1, $&, $), flags m, s and u, and friendly error messages for invalid patterns.
  • Whole-word matching that understands accented letters.
  • Runs regular expressions in a background worker with a time limit, so a pattern that loops forever cannot freeze the page.

Limitations

  • Very complex patterns that run for more than about two and a half seconds are stopped and you are asked to simplify them.
  • Texts above 1,000,000 characters are refused to keep the page responsive.
  • JavaScript regular expression syntax applies; features of other engines (such as possessive quantifiers or \A) are not available.
  • The highlighted preview shows the first 50,000 characters and the first 1,000 matches; the result is always complete.
  • Results are computed in your browser; nothing you enter is sent to a server.

Example

Replacing (\d+)-(\d+) with $2-$1 in “10-20 and 3-4” (regex mode) gives “20-10 and 4-3”. Replacing “cat” with “dog” using Whole words only leaves “category” untouched.

Frequently Asked Questions

What is the difference between plain text and regex mode?

In plain mode every character is searched literally, so a dot is just a dot. In regex mode characters such as . * + ? ( ) [ ] have special meanings and let you describe patterns.

How do I use capture groups in the replacement?

Put part of the pattern in parentheses, then refer to it as $1, $2 and so on in the replacement. $& inserts the whole match. Plain text mode inserts the replacement exactly as typed.

Why does it say my pattern took too long?

Some patterns, for example nested quantifiers such as (a+)+$, can take exponential time on certain text. The tool stops them after a few seconds. Simplify the pattern or make it more specific.

Can I replace only the first match?

Yes, tick Replace only the first match. Otherwise every match is replaced.

Does it support line breaks in the search?

In plain mode tick the \n and \t option and type \n for a line break. In regex mode \n works directly.

Related Tools

More like this: all Text Cleanup tools, all Text & Writing tools or the TinySandy home page.