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
- Paste your text in Your text.
- Type the word or pattern in Find and the new text in Replace with.
- Use Match case, Whole word only or Regular expression to refine the search.
- 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
| Option | When it is off | When it is on |
|---|---|---|
| Match case | Cat, cat and CAT all match | Only the exact capitalization matches |
| Whole word only | The search can match inside longer words | The match must not touch another letter, digit or underscore |
| Regular expression | The search text is taken literally, special characters included | The search text is a pattern, and the replacement can use $1, $2, \n and \t |
Worked examples
- Use the sample text
The cat sat on the mat. Another cat saw the concatenation.with Find =catand Replace with =dog. The result isThe dog sat on the mat. Another dog saw the condogenation.with 3 in Matches replaced. The third match was inside the word concatenation. - 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 forcafwould not match the start of café. - Tick Regular expression, put
(\w+), (\w+)in Find and$2 $1in Replace with, and use the textSmith, Johnon one line andDoe, Janeon the next. The result isJohn SmithandJane Doe, with 2 matches. Each pair in parentheses is a group, and$1and$2put the groups back in the new order.
Patterns worth knowing
| Pattern | Matches |
|---|---|
\d+ | One or more digits |
\s{2,} | Two or more whitespace characters in a row. Replacing with one space collapses extra spaces |
colou?r | Both color and colour |
\bfoo\b | The word foo as a whole word |
Tips and common mistakes
- Without regex, what you type is literal. Typing
\nin 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.