Find and Replace Text

Replace every occurrence of a word or phrase at once, with optional regular expressions for power users.

Last reviewed:

Plain search, whole words and match case

A plain search finds your text anywhere, even inside longer words. Replace “cat” with “dog” in “the cat sat in the category” and you get “the dog sat in the dogegory”. Whole words limits matches to standalone words, and Match case separates May the month from may the verb.

FindTextPlainWhole words
catthe cat sat in the category2 matches1 match
heshe and the help3 matches0 matches

Match case matters for names and acronyms. Searching “May” in “May I visit in May? You may.” finds 3 matches normally, but only the 2 capitalized ones with Match case on.

Look at the match count before you copy anything. If you expected 3 changes and see 41, a partial match is almost certainly hiding inside other words.

Regular expression cheat sheet

With Regular expression on, some characters become instructions instead of literal text. These cover most everyday jobs.

PatternMatchesExample
.Any single character except a line breakc.t finds cat, cut, c9t
\dA digit, 0–9\d\d finds 42
\wAn unaccented letter, digit or underscore\w+ finds user_42
\p{L}A letter in any language, accents included\p{L}+ finds José
\sAny whitespace, including line breaks\s+ finds a run of spaces
\nA line breakReplace \n with a comma to join lines
+ * ?One or more, zero or more, optionalcolou?r finds color and colour
{4}Exactly 4 of the previous item\d{4} finds 2027
[ae]Any one of the listed charactersgr[ae]y finds gray and grey
[^0-9]Any character not listed[^0-9] finds every non-digit
( )A group you can reuse as $1, $2(\d+) captures a number
|Either sidecat|dog finds both
\bA word boundary\bcat\b skips category
^ and $The start and end of each line^Dear finds Dear at the start of any line

To match a symbol that has a special meaning (. * + ? ( ) [ ] { } ^ $ | or a backslash), put a backslash in front of it. Searching “$5.00” in regex mode finds nothing, because $ means “end of line”; “\$5\.00” finds the price.

Worked examples with capture groups

Parentheses capture part of a match, and $1, $2 and so on put those parts back in the replacement in any order. $& inserts the whole match.

Example: US dates to year-month-day

  1. Find: (\d{2})/(\d{2})/(\d{4})
  2. Replace with: $3-$1-$2
  3. “Due 12/31/2026” becomes “Due 2026-12-31”

Every date in the text is converted in one pass.

Example: Surname first to first name first

  1. Find: (\p{L}+), (\p{L}+)
  2. Replace with: $2 $1
  3. “García, José” becomes “José García”
  4. With \w instead of \p{L}, the same line comes out as “GarcíJos aé”

Use \p{L} for names. \w only knows unaccented letters, so it splits names at the accent.

Two more quick ones. Find \s*\[\d+\] and replace with nothing to strip reference markers like [12] from copied text. Find \d+ and replace with ($&) to put every number in brackets: “Costs 15 and 300” becomes “Costs (15) and (300)”.

Everyday jobs that don't need regex

Most find-and-replace work is plain text with the right options. A few that come up again and again in offices and classrooms:

  • Roll a year forward in a template: find 2025 with Whole words on and replace with 2026, so a reference number like 20251 is left alone.
  • Standardize spelling across a document: “e-mail” to “email”, or “color” to “colour” for a UK client.
  • Swap curly apostrophes for straight ones before pasting into a form or text message.
  • Rename a character or product in a draft, with Match case on so “Rose” changes but “rose” the flower doesn't.
  • Delete a repeated phrase entirely by leaving Replace with empty.

Swapping two words without losing one

Replacing “left” with “right” and then “right” with “left” leaves you with nothing but “left”, because the second step also catches the words you just changed. Use a temporary placeholder that doesn't appear anywhere in the text.

Example: Swapping left and right in driving directions

  1. Replace left with TEMP (check the count is what you expect)
  2. Replace right with left
  3. Replace TEMP with right

“Turn left, then right” becomes “Turn right, then left”. Apply each step to the original before running the next.

Common mistakes

  • Forgetting Whole words, so “he” also changes “the”, “she” and “help”.
  • Leaving Match case off when capitals matter, as in brand names or acronyms.
  • Greedy patterns. The regex ".*" (a quote mark, anything, a quote mark) grabs everything from the first quote on a line to the last one. Use "[^"]*" or ".*?" to stop at the nearest closing quote.
  • Forgetting that ^ and $ work line by line here. ^\s+ removes the indentation from every line at once, which is handy, but only if that's what you meant.
  • Fixing the wrong thing. To tidy spacing, Remove Extra Spaces is faster; to change capitals, use the Case Converter.

Sources and further reading

How to use it

  1. 1Paste your text.
  2. 2Type what to find and what to replace it with.
  3. 3Copy the result. The match count shows what changed.

Questions

Can I use regular expressions?

Yes. Turn on Regex; use $1, $2 in the replacement to insert captured groups.

Is my text uploaded anywhere?

No. Everything happens in your browser; your text never leaves your device.

Also handy: Text to QR Code, Shuffle a List