How to use find and replace
- Paste your text in the top box.
- Type what to look for in Find and what to put instead in Replace with. Leave the replacement empty to delete every match.
- The result updates as you type, with a count of how many places changed. Open Show matches highlighted to check exactly which parts were matched before you copy the result.
Three switches control matching: Match case makes Cat and cat different, Whole words only stops cat matching inside category, and Regular expression treats the Find box as a pattern.
Plain text mode
By default, the Find box is treated as ordinary text, so characters such as . * ? ( ) [ ] mean exactly what they look like. You can search for 3.5, (draft) or $100 without any special syntax, and the replacement is inserted literally, so a dollar sign in it is not interpreted.
With Whole words only on, a match counts only if the characters on either side are not letters, digits or underscores. This works for any language, including accented letters and Urdu, because the boundary check uses Unicode letters instead of just A to Z.
Regular expression mode
Tick Regular expression to use pattern matching. The most useful pieces are:
| Pattern | Matches | Example |
|---|---|---|
\d+ | One or more digits | Find \d+ in “Room 42” → 42 |
\s+ | One or more spaces, tabs or line breaks | Collapse gaps by replacing with one space |
^ and $ | Start and end of the text | Use with a text you want to add before everything |
[aeiou] | Any one of the listed characters | Find vowels |
(\w+)@(\w+) | Groups you can reuse as $1, $2 | Replace with $2 at $1 |
colou?r | The previous character is optional | Matches both colour and color |
In the replacement box you can use $1, $2 for captured groups, $& for the whole match, and \n or \t for a new line or tab. If your pattern is not valid, an error explains the problem in the box above the result and your text is left unchanged.
Worked examples
- Whole word. The sample text has “cat” in cat, category and Cat. With whole words on and case ignored, “cat” → “dog” changes two places and leaves category alone: “The dog sat on the category sheet; the dog was not amused.”
- Reformat phone numbers. Regex mode, Find
(\d{4})-(\d{7}), Replace+92 $1 $2. “0300-1234567” becomes “+92 0300 1234567”. - Swap first and last names. Find
(\w+), (\w+), Replace$2 $1. “Khan, Ali” becomes “Ali Khan”. - Collapse runs of spaces. Regex mode, Find
\s{2,}, Replace with a single space. For a fuller clean-up, use the remove extra spaces tool. - Turn a list into one line. Regex mode, Find
(a line break), Replace,. A column of names becomes “Ali, Sara, Omar”.
Common mistakes
- Forgetting special characters in regex mode. A dot matches any character, so searching for
3.5also finds “3x5”. Write3\.5or switch regex off. - Replacing too much. Searching for “is” without whole words also changes “this” and “island”. Check the highlighted preview first.
- Greedy patterns.
<.*>matches from the first < to the last > on a line. Use<.*?>to stop at the first >. - Forgetting case. If a replacement “did nothing”, check whether Match case is ticked and the capital letters differ.
Handy find and replace recipes
| Goal | Mode | Find | Replace with |
|---|---|---|---|
| Remove all digits | Regex | \d+ | (empty) |
| Change every straight apostrophe to a curly one | Plain | ' | ’ |
| Remove text in brackets | Regex | \s*\([^)]*\) | (empty) |
| Replace a whole word only | Plain + whole words | colour | color |
| Convert tabs to commas | Regex | \t | , |
| Remove blank lines | Regex | \n{2,} | \n |
| Put quotes around each number | Regex | (\d+) | "$1" |
When a recipe might match more than you expect, tick the highlighted preview first. It shows every matched piece in the original, so a pattern that is too wide is easy to spot before you copy the result.
Accuracy and limits
The tool follows JavaScript's regular expression rules, which differ slightly from other languages such as PCRE or Python. Very complex patterns with nested repeats can be slow on long texts. Highlighting is limited to the first 60,000 characters of matches, though the result and count still cover the full text. Nothing is uploaded, and your pattern is not saved.
Frequently asked questions
Does find and replace change all matches at once?
Yes, it replaces every match in the text. The count above the result shows how many places were changed, so you can sense-check it before copying.
How do I replace only whole words?
Tick “Whole words only”. The word “cat” then matches “cat” but not “category” or “concatenate”.
What is a regular expression?
A pattern that describes text, such as “any run of digits” or “a word followed by a comma”. It lets one search match many different strings. It is optional: leave the box unticked for ordinary searching.
Why does my pattern show an error?
A regular expression must be complete, with brackets paired and special characters used correctly. The error message explains what the browser did not understand, such as an unmatched parenthesis.
Can I undo a replacement?
Your original text stays in the top box. The result is shown separately and only replaces the input if you press “Use result as input”.