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.
| Find | Text | Plain | Whole words |
|---|---|---|---|
| cat | the cat sat in the category | 2 matches | 1 match |
| he | she and the help | 3 matches | 0 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.
| Pattern | Matches | Example |
|---|---|---|
| . | Any single character except a line break | c.t finds cat, cut, c9t |
| \d | A digit, 0–9 | \d\d finds 42 |
| \w | An unaccented letter, digit or underscore | \w+ finds user_42 |
| \p{L} | A letter in any language, accents included | \p{L}+ finds José |
| \s | Any whitespace, including line breaks | \s+ finds a run of spaces |
| \n | A line break | Replace \n with a comma to join lines |
| + * ? | One or more, zero or more, optional | colou?r finds color and colour |
| {4} | Exactly 4 of the previous item | \d{4} finds 2027 |
| [ae] | Any one of the listed characters | gr[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 side | cat|dog finds both |
| \b | A 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
- Find: (\d{2})/(\d{2})/(\d{4})
- Replace with: $3-$1-$2
- “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
- Find: (\p{L}+), (\p{L}+)
- Replace with: $2 $1
- “García, José” becomes “José García”
- 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
- Replace left with TEMP (check the count is what you expect)
- Replace right with left
- 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.