Find and Replace
The two toggles that prevent almost every disaster
Nearly every find-and-replace horror story — the report where "manager" became "womanager", the codebase where a variable rename corrupted a dozen longer names — comes from the same oversight: the find text was matched inside other words. Plain replacement is literal and fearless: ask it to replace "cat" and it will cheerfully rewrite catalogue, concatenate and caterpillar. Whole-word mode exists to stop exactly that. It requires each match to be bounded by a word edge — a space, punctuation or the start or end of the text — so only the standalone animal is replaced. Whenever your find text is a short common string, whole-word mode is not an refinement; it is the difference between a clean edit and a corrupted document. The live match count is your second safety net: if you expected 12 matches and the counter says 340, the settings are wrong, and you find that out before a single character changes.
Case sensitivity is the subtler choice. Case-insensitive replacement is usually what people mean for prose — a name, a product, a place should be caught however it was capitalised — but it has a trap of its own: the replacement text is inserted exactly as you typed it, so replacing "Cat" and "CAT" with "dog" flattens their capitalisation too. If the capitalised forms matter (sentence starts, acronyms), run the replacement in passes: replace the lowercase form case-sensitively, then handle the capitalised variants one by one with their own replacement casing. Professional editors do this instinctively; the live count makes it easy, because each pass reports exactly how many instances it is about to touch.
When a regular expression earns its keep
A regular expression matches a shape instead of a fixed string, and three everyday jobs justify learning the basics. First, dates: the pattern \d{1,2}/\d{1,2}/\d{4} finds every date in day/month/year form whatever the actual numbers are — impossible with literal search, which would need 366 searches for one year alone. Second, whitespace damage: \s+ replaced with a single space collapses the double spaces, stray tabs and mixed runs that pasted text accumulates (our Remove Extra Spaces tool does this one job with no pattern required). Third, restructuring: capture groups let the replacement rearrange what was found — (\w+), (\w+) replaced with $2 $1 turns "Ahmed, Sara" into "Sara Ahmed" across a whole list at once. The price of this power is that a malformed pattern fails completely, which is why this tool reports an invalid regex in plain English and refuses to touch your text until the pattern parses. Start patterns small, watch the live count, and grow them one piece at a time.
Worked example
Text: "the cat sat. The cat ran. THE CAT slept." Find: cat → Replace: dog.
Case-insensitive (default): 3 replacements — "the dog sat. The dog ran. THE DOG slept." Note the third match keeps the original's position but takes the replacement's lowercase form.
Case sensitive on: 2 replacements — only the two lowercase "cat"s change; "THE CAT" is left untouched.
Whole words off vs on: in a text containing "catalogue", plain mode would rewrite it to "dogalogue"; whole-word mode leaves it alone. The live count differs by exactly the number of embedded matches.
Quick reference: useful patterns
| Pattern | Matches |
|---|---|
| \d+ | Any run of digits (a number of any length) |
| \s+ | Any run of whitespace — spaces, tabs, newlines |
| \b\w+@\w+\.\w+\b | Email-shaped strings (approximately) |
| ^(.+)$ | Each whole line (with multiline text, applied per line by the replacement) |
| (\w+), (\w+) | "Surname, Firstname" pairs, for swapping with $2 $1 |
Frequently asked questions
How does the match count work?
The count is live: as you type the find text, the tool counts how many matches exist in your text right now, under the toggles you have set, before anything is replaced. Press Replace All and the output appears with the number of replacements actually made, so you can confirm the two numbers agree. If the live count surprises you — far more or far fewer matches than expected — that is the moment to adjust the toggles rather than after the damage is done.
What is the difference between case-sensitive and whole-word matching?
Case-sensitive matching treats Cat, cat and CAT as three different strings; case-insensitive matching treats them as one. Whole-word matching requires the find text to stand alone, bounded by spaces or punctuation, so finding 'cat' will not touch the cat inside 'catalogue' or 'concatenate'. The two combine freely: in the sentence 'the cat sat. The cat ran. THE CAT slept.', replacing cat with dog gives 3 replacements case-insensitively, but only 2 with case sensitivity on, because THE CAT no longer counts.
What is a regular expression and when should I use one?
A regular expression (regex) is a pattern language for matching shapes of text rather than exact strings: \d+ matches any run of digits, \s+ any run of whitespace, ^ and $ match the start and end of a line. Regex earns its complexity when the thing you want varies: every date in a document whatever the day, double spaces however many there are, or prices in any currency format. For a fixed word or phrase, plain mode is faster to get right and much harder to get wrong.
What does the error 'invalid regular expression' mean?
It means the pattern you typed cannot be interpreted — usually an unclosed bracket or parenthesis, a backslash with nothing after it, or a quantifier like + with nothing in front of it. The tool shows the browser's own error message in plain form and leaves your text untouched, so nothing is half-replaced. Fix the pattern (the usual culprits are ( [ and \) and the live count returns the moment the pattern is valid again.
Is my text uploaded or stored?
No. Finding, counting and replacing all happen in your browser; your text is never sent to a server or stored anywhere. That matters for the documents find-and-replace is typically used on — drafts, contracts, code and lists of names — none of which belong on a stranger's server for the sake of a substitution.
Related tools
Examples and tool logic last verified: 24 November 2026. Everything is calculated in your browser — nothing you type is sent anywhere.