What This Tool Does
This find and replace tool searches any text for a target string or regex pattern and replaces it with a new string. Options include case-sensitivity, whole-word matching, regex mode, and match counting. Useful for cleaning data, refactoring content, or bulk editing documents.
Inputs Explained
- Source Text: The text you want to search within.
- Find: The string or regex pattern to search for.
- Replace With: The string to substitute. Leave blank to delete matches. Use $1, $2 for regex capture groups.
- Case Sensitive: When checked, only exact-case matches are replaced.
- Whole Word: Match whole words only, not substrings (ignored in regex mode).
- Regex Mode: Treat Find as a JavaScript regex pattern (without the slashes).
How It Works
The tool builds a JavaScript RegExp from your input (escaping special characters if regex mode is off), applies appropriate flags (g for global, i for case-insensitive), and uses String.replace to perform the substitution. It also counts matches before replacing so you can preview the change count.
Formula / Logic Used
Find and Replace Text (with Regex)
Find and replace text instantly with regex, case, and whole-word options.
Step-by-Step Example
Source: The cat sat on the mat. Another cat was there too.
Find: cat | Replace: dog | Whole word: ✓
Result: The dog sat on the mat. Another dog was there too.
Regex example: Find (\d{4})-(\d{2})-(\d{2}), Replace $3/$2/$1 converts YYYY-MM-DD dates into DD/MM/YYYY format across the entire text.
Use Cases
- Content editing: Quickly fix a typo or brand name change across a long document.
- Code refactoring: Rename a variable or function across pasted code snippets with whole-word matching.
- Data cleanup: Standardize phone number formats, date formats, or address fields using regex capture groups.
- SEO audit: Find every occurrence of an old URL to update in bulk content export.
- Email personalization: Replace placeholders like {FirstName} with real values before sending.
Assumptions and Limitations
- Regex mode uses JavaScript regex syntax, which differs slightly from Python or PCRE (no lookbehind variations in older browsers).
- Very large inputs (>5 MB) combined with complex regex patterns may slow the browser significantly.
- Whole-word matching uses \b word boundaries, which treat hyphens and apostrophes as word breaks.
- The tool does not support step-by-step replacement preview — all replacements happen at once.
Frequently Asked Questions
How do I use regex in the find field?
Check 'Regex mode' and enter the pattern without surrounding slashes. For example, to match any 4-digit year, use \d{4}. To match an email, use [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}.
What are capture groups?
Parentheses in a regex capture matched text into groups you can refer to in the replacement as $1, $2, etc. Example: Find (\w+) (\w+), Replace $2 $1 — this swaps every pair of words.
What's the difference between whole-word and case-sensitive?
Case sensitive matches only when uppercase/lowercase match exactly. Whole-word matches only when the search term is surrounded by word boundaries (punctuation, spaces) — 'cat' won't match 'category'.
Why isn't my regex matching anything?
Common causes: you included slashes (remove them), used Python syntax (like named groups with ?P
Is the replacement reversible?
No — once you click Replace All, the new text appears in the result. Your original text remains in the input box, so you can copy it back and try again with different find/replace values.
Can I use multi-line regex?
JavaScript regex doesn't have a standard multi-line mode flag here, but \n matches newlines within the text. For multi-line patterns, use (.|\n) instead of . to match across lines.
How do I replace special characters like newlines or tabs?
In regex mode, use \n for newline and \t for tab. In the replacement field, \n and \t also work. Example: replace \n with | to convert a list to comma-separated (pipe-separated).
Is my text stored anywhere?
No. All processing runs entirely in your browser. Source text and regex patterns never leave your device.
Sources and References
- MDN — Regular Expressions — Comprehensive JavaScript regex reference.
- MDN — String.prototype.replace — The core replace method used by this tool.
- Regex101 — Test and debug regex patterns interactively.
- ECMAScript Specification — RegExp — Official regex syntax specification.