Worked example: whole words and reordered dates
In “The cat sat by the category list; Cat food is in the catalog.”, a plain replacement of cat with dog makes 4 changes and damages two words: “The dog sat by the dogegory list; dog food is in the dogalog.”. With whole words only ticked it makes 2 changes: “The dog sat by the category list; dog food is in the catalog.”. To turn ISO dates into US order, use the regular expression (\d{4})-(\d{2})-(\d{2}) with the replacement $2/$3/$1: “Invoice 3 is due 2026-12-01 and invoice 4 is due 2027-01-15.” becomes “Invoice 3 is due 12/01/2026 and invoice 4 is due 01/15/2027.”.
Regular expression cheat sheet
| Pattern | Matches |
|---|---|
\d / \d+ | One digit / a whole number |
\s+ | Any run of spaces, tabs or line breaks |
^ and $ | The start and end of each line |
colou?r | “color” and “colour” (the u is optional) |
(Mr|Mrs|Ms)\. | Any of the three titles, captured as $1 |
[A-Z]{2}\d{4} | Two capitals then four digits, like AB1234 |
\p{L}+ | A word in any alphabet |
Useful clean-ups: replace [ \t]+$ with nothing to strip spaces at line ends; replace \n{3,} with \n\n to collapse runs of blank lines; replace \s*,\s* with , to tidy commas.
Why a time limit?
A regular expression engine tries every way a pattern could match before giving up. For most patterns that is instant, but a pattern like (a+)+$ on a long line of a’s ending in another letter has to try an exponential number of combinations, which can freeze a browser tab for minutes. This is known as catastrophic backtracking, and it has taken down real websites. Here each search runs apart from the page and is stopped after two seconds, and a warning appears as you type when a pattern has the risky shape of a repeated group inside another repetition.
Plain replacements are literal
Without “Regular expression” ticked, every character means itself: a full stop is a full stop and $1 in the replacement is the text “$1”. That makes plain mode safe for replacing prices, file paths and code, where symbols would otherwise have special meanings.
Real jobs for find and replace
- Rebranding a document: replace an old product or company name everywhere, with whole words on so that longer words containing it are left alone.
- Cleaning exported data: remove currency signs, change semicolons to commas, or strip “Mr”, “Mrs” and “Ms” from a list of names with a single pattern.
- Templates: fill placeholders such as {name} or [DATE] in a letter or e-mail before sending it.
- Code and configuration: rename a variable, change a URL in every line, or reorder captured parts with $1 and $2.
Check the highlighted matches before you copy the result: they show exactly which parts of the text will change, and the count tells you whether the pattern caught more or fewer places than you expected.
Related tools
Sources
Checked on November 26, 2026:
- ECMAScript Language Specification: RegExp (regular expression) objects
- OWASP: Regular expression Denial of Service (ReDoS)
- Unicode Technical Standard #18: Unicode Regular Expressions
Frequently asked questions
How do I find and replace text online?
What does “whole words only” do?
How do I use a regular expression?
Why was my search stopped?
Can I add a new line in the replacement?
Is my text sent anywhere?
Last updated: 2026-11-26