FA
Find and Replace
Search and replace text with live match counting, case sensitivity, whole-word and regex options.
More Text & Writing Tools
matches found
How to Use Find and Replace
Paste your text, type what to find and what to replace it with, and see a live match count as you type. Toggle case-sensitivity, whole-word-only matching, and full regex mode. Click "Replace All" to generate the replaced text in a separate output box (your original input is never modified) with a one-click Copy button.
About Find and Replace
Find and replace is one of the most reached-for text operations there is, but a plain literal search misses a lot of real-world cases: you might need a case-insensitive match, a match that only counts when the search term is a whole word (so replacing "cat" doesn't also touch "category" or "scatter"), or a pattern-based match that covers many variations at once (any phone-number-like sequence, any line starting with a number, and so on). This tool covers the full range from simple literal replace up to full regular-expression find-and-replace, in one interface.
By default, the Find field is treated as a literal string: whatever you type is matched exactly as written, including any characters that would otherwise have special meaning in a regular expression (like `.`, `*`, `(` or `[`). Internally, this is implemented by escaping every regex metacharacter in your search term before using it — so searching for a literal `3.14` will not accidentally also match `3x14` the way an unescaped `.` (which means "any character" in regex) would. Turning on "Use regex" removes that escaping step and passes your Find text directly to JavaScript's `RegExp` engine as a pattern, unlocking everything from character classes (`[0-9]+`) to alternation (`cat|dog`) to capture groups you can reference in the Replace field using `$1`, `$2`, and so on — a genuinely powerful feature for anyone comfortable with regex syntax, and completely optional for anyone who is not.
"Whole word only" wraps whatever pattern is being used — literal or regex — in `\b...\b`, the regex word-boundary anchor, so a search for `cat` only matches `cat` as a standalone word and does not also match the `cat` inside `category`, `scattered`, or `concatenate`. This combines with both literal and regex mode: turn it on with a literal search for precise whole-word matching, or combine it with a regex pattern for a more targeted match. "Case-sensitive" defaults to off (so `Hello` and `hello` are treated as the same match) and, when turned on, requires an exact case match.
The match count updates live as you type in either the source text or the Find field, or as you toggle any of the three options — so you always know exactly how many replacements Replace All is about to make before you commit to it, without needing to click a separate "preview" button. If your Find text is not valid as a regular expression — an unclosed bracket, an invalid quantifier, and so on — this only matters when "Use regex" is on (a literal search is always automatically escaped into something valid), and the tool catches the resulting error from the `RegExp` constructor and shows it inline in red rather than letting an uncaught JavaScript exception silently break the page; the match count simply reads zero until the pattern is fixed, and if you already had a previous successful Replace All result on screen, it stays there untouched rather than being wiped out by the new error.
Replace All never modifies your original source text — the replaced text always appears in a separate, clearly labeled result box below, so you can compare before and after, run a different find/replace pass starting from the same original text, or simply copy the result out once you're happy with it via the one-click Copy button.
Details & Tips
How matching works: the Find text is turned into a `RegExp` object. If "Use regex" is off, every regex metacharacter (`. * + ? ^ $ { } ( ) | [ ] \`) in your Find text is escaped first, so it is matched as a literal string regardless of what characters it contains. If "Use regex" is on, your Find text is used directly as the regex pattern, letting you use character classes, alternation, quantifiers, anchors and capture groups.
How "Whole word only" works: the (possibly-escaped) pattern is wrapped in a non-capturing group and surrounded by `\b` word-boundary anchors — `\b(?:pattern)\b` — so the match only counts when it falls on a word boundary on both sides, preventing partial-word matches like "cat" inside "category".
How case sensitivity works: the regex is built with the `i` (case-insensitive) flag unless "Case-sensitive" is checked, in which case the flag is omitted and matching requires an exact case match.
How the live match count works: the same regex (always built with the global `g` flag internally, regardless of your other toggles) is run against the source text with `RegExp.exec()` in a loop, counting each match, with a safeguard that advances past zero-length matches so a pattern that can match an empty string (like `x*`) cannot cause an infinite loop.
How Replace All works: `String.prototype.replace()` is called with the same regex and your Replace text as the replacement — if "Use regex" is on and your pattern contains capture groups, you can reference them in the Replace field with `$1`, `$2`, etc., the standard JavaScript replacement-pattern syntax. The result is written to a separate field; your original source text is never mutated, so you can freely try different Find/Replace combinations starting from the same source.
Error handling: if "Use regex" is on and the pattern is invalid, the `RegExp` constructor throws, which is caught and shown as an inline red error message rather than crashing the page. The match count resets to zero while the pattern is invalid, but any previously generated Replace All result stays visible until you run a new, valid replacement.
Worked example: source `The cat sat on the category of mats`, Find `cat`, whole word only ON → matches only the standalone "cat", not the "cat" inside "category" → 1 match found. With whole word only OFF, both are matched → 2 matches found.
Frequently Asked Questions
Does Find and Replace modify my original text?
No, the replaced text always appears in a separate output box below your source text. Your original input is never overwritten, so you can try different searches starting from the same text.
What is the difference between "Use regex" on and off?
With it off, your Find text is matched literally, character for character (any regex special characters like . or * are treated as plain text). With it on, your Find text is interpreted as a full regular expression pattern, letting you use character classes, alternation and capture groups.
What happens if I type an invalid regex pattern?
An inline red error message appears explaining the problem, the match count shows zero, and the page does not crash. Any previous Replace All result you already generated stays on screen until you fix the pattern and run it again.
How does "Whole word only" prevent partial matches?
It wraps your search pattern in \b...\b word-boundary anchors, so "cat" will match the standalone word "cat" but not the "cat" inside "category" or "scattered".
Can I use capture groups in the replacement text?
Yes, when "Use regex" is on and your Find pattern has capture groups like (\d+), you can reference them in the Replace field with $1, $2, and so on, using standard JavaScript replacement syntax.
Is the match count accurate before I click Replace All?
Yes, it updates live as you type in either box or change any toggle, and reflects exactly how many replacements Replace All would make if you clicked it right now.
Is matching case-sensitive by default?
No, case-sensitivity is off by default, so "Hello" and "hello" are treated as matches for each other. Check "Case-sensitive" to require an exact case match.
Can I replace text with an empty string to delete it?
Yes, leave the Replace field empty and click Replace All — every match of your Find text will be removed from the result.
Does this tool protect against a regex pattern that could freeze the page?
Zero-length matches (patterns that can match an empty string) are specifically guarded against to prevent an infinite counting loop. Extremely complex patterns with catastrophic backtracking on very large text are a general JavaScript regex engine limitation, not something this tool can fully prevent.
Is my text uploaded to a server?
No, all matching, counting and replacing happens locally in your browser using JavaScript.
Can I copy the replaced result?
Yes, a Copy button appears above the result box once you click Replace All, copying the full replaced text to your clipboard.
Why does my whole-word regex search for a phrase with spaces not work as expected?
\b matches at a transition between a word character and a non-word character, so wrapping a multi-word phrase in \b...\b still works correctly at the phrase's outer edges, but keep in mind punctuation immediately adjacent to your phrase (like a comma with no space) can affect whether a boundary is detected there.
Part of These Collections
Also Available As
find and replace, text replace tool, regex replace online, search and replace text, bulk find replace, whole word replace
Explore More Tools
View all toolsFound a Problem?
Let us know if something with Find and Replace isn't working as expected.
Something went wrong. Please try again.
Thanks — we'll take a look.