Guide
How to Find and Replace Text (Including With Regex)
Master find-and-replace from simple swaps to regex patterns, and learn safe habits that prevent costly mistakes.
Find-and-replace locates every occurrence of a search string and swaps it for a replacement. Simple mode matches literal text; regex mode matches patterns, which is far more powerful but demands care.
Simple vs. regex replacement
In simple mode, searching for "cat" replaces every literal "cat" — including inside "category". Regex mode lets you match patterns: word boundaries, digits, repetition, alternatives. Searching for "\bcat\b" with regex replaces only the standalone word "cat", leaving "category" untouched.
Useful regex patterns for replacement
- \b — word boundary, to match whole words only.
- \d+ — one or more digits.
- \s+ — one or more whitespace characters.
- .*? — any characters, non-greedy.
- (abc|xyz) — either "abc" or "xyz".
- ^ and $ — start and end of a line.
How to use find-and-replace safely
- Back up your original text before a large replace.
- Start with case-sensitive matching to avoid unintended swaps.
- Use word boundaries (\b) when replacing common words.
- Review a preview of matches before applying if available.
- Test regex on a small sample first.
Examples
Replacing "colour" with "color" in simple mode swaps every occurrence — useful for British-to-American spelling. With regex, replacing "\b\d{4}\b" with "YEAR" turns every standalone 4-digit number into "YEAR", ideal for anonymising dates in a transcript.
When find-and-replace is useful
- Bulk-renaming terms across a document or codebase.
- Standardising spelling, capitalisation, or formatting.
- Redacting or anonymising sensitive patterns.
- Cleaning imported data before analysis.
Put it into practice
Use the Find & Replace right now — free, in your browser, no sign-up required.
Try the Find & ReplaceMore guides
- How to Unscramble Letters Into Words
- How to Find Anagrams of Any Word
- How to Count Words, Characters and Reading Time Accurately
- How to Find Words by Pattern, Length and Letters
- How to Use a Random Word Generator for Games, Writing and Brainstorming
- How to Count Characters (With and Without Spaces)
- How to Convert Text Between Cases (UPPER, lower, Title, camelCase and More)
- How to Clean Up Messy Text (Spaces, Line Breaks and Whitespace)
Related free tools
More free online utilities that pair well with this one — same-category tools for the same task, plus handy extras from other categories.