Find and replace

Paste your text, type what to find and what to replace it with, and get the result instantly with the number of matches. Supports match case, whole words and regex. Free, and nothing leaves your browser.

How to use it

  1. Paste your text in Your text.
  2. Type the word or pattern in Find and the new text in Replace with.
  3. Use Match case, Whole word only or Regular expression to refine the search.
  4. Check Matches replaced and copy the result.

Guide to find and replace in text

What it does

Find and replace swaps every occurrence of one piece of text for another across a whole document in one step. It is the quickest way to rename a product in a long description, change a date format in a list, fix a repeated typo, or clean up exported data. You see the result and the number of replacements at once, and the original text in the box is not changed until you copy the result out. It runs in your browser, so the text is not uploaded.

The three options

OptionWhen it is offWhen it is on
Match caseCat, cat and CAT all matchOnly the exact capitalization matches
Whole word onlyThe search can match inside longer wordsThe match must not touch another letter, digit or underscore
Regular expressionThe search text is taken literally, special characters includedThe search text is a pattern, and the replacement can use $1, $2, \n and \t

Worked examples

  1. Use the sample text The cat sat on the mat. Another cat saw the concatenation. with Find = cat and Replace with = dog. The result is The dog sat on the mat. Another dog saw the condogenation. with 3 in Matches replaced. The third match was inside the word concatenation.
  2. Now tick Whole word only. The count drops to 2 and the result is The dog sat on the mat. Another dog saw the concatenation. Accented Latin letters are treated as part of a word, so a search for caf would not match the start of café.
  3. Tick Regular expression, put (\w+), (\w+) in Find and $2 $1 in Replace with, and use the text Smith, John on one line and Doe, Jane on the next. The result is John Smith and Jane Doe, with 2 matches. Each pair in parentheses is a group, and $1 and $2 put the groups back in the new order.

Patterns worth knowing

PatternMatches
\d+One or more digits
\s{2,}Two or more whitespace characters in a row. Replacing with one space collapses extra spaces
colou?rBoth color and colour
\bfoo\bThe word foo as a whole word

Tips and common mistakes

  • Without regex, what you type is literal. Typing \n in Replace with inserts the two characters backslash and n, not a line break. Tick Regular expression to get a real line break.
  • With regex on, the characters . * + ? ( ) [ ] { } | ^ $ \ have special meaning. To find a literal full stop, write \..
  • The anchors ^ and $ refer to the start and end of the whole text, not of each line. Searching for ^ in two lines changes only the very beginning.
  • An empty Find box does nothing, and an invalid pattern shows an error instead of a result.
  • Make a copy of important text before pasting the result over it, because replacements cannot be undone from here.

Related tools

To check exactly what changed between two versions, use the text diff. To build and test patterns first, use the regex tester. For stray spaces, see the extra space remover.

Questions

What does Whole word only do?

It replaces the term only when it stands alone, so "cat" is replaced but "concatenation" is left alone.

How do I use regular expressions?

Tick Regular expression and write a JavaScript pattern, for example \d+ for numbers. In the replacement, $1 and $2 insert captured groups.

Why does it say the expression is not valid?

The pattern has a syntax error, such as an unclosed parenthesis. Fix it or untick Regular expression to search for the exact text.

Is my text sent to a server?

No. Everything runs in your browser and nothing is uploaded or stored.