Search · Replace · Regex

Find & Replace

Search for text and replace it — with regex, case options, and live preview.

Text
Enter a search term to preview matches.
Advertisement

About the Find & Replace tool

Find a string or pattern in any text and replace it — case-sensitive or case-insensitive, plain string or regex, with optional whole-word matching. Useful for cleaning up data, batch-renaming, fixing typos, and any text-transformation that's tedious to do by hand. Everything runs locally in your browser; nothing is uploaded.

What Find & Replace does

The operation is simple: locate every occurrence of one string and replace it with another. The complications come from two questions: which occurrences (case-sensitive matches, partial matches, whole-word matches, regex matches) and how to replace them (literal replacement, backreference substitution, special character handling). This tool exposes both as explicit options so you can pick the right combination for the job.

Plain mode does what most users want most of the time — find a literal string, replace with another literal string. Regex mode unlocks pattern matching for the cases where plain mode isn't enough. Case-insensitive matching catches "Foo" when you searched for "foo." Whole-word matching prevents "form" from matching inside "format."

Real use cases

Bulk-renaming variables in code snippets. Refactoring a function name across a code sample without touching every reference manually. Whole-word matching is essential — without it, "user" matches inside "username" too.

Fixing typos repeated throughout a document. If you misspelled "Anthropic" as "Antrhopic" twelve times in a long blog post, find-and-replace fixes them in one operation rather than twelve.

Cleaning data from CSV exports. Replace empty placeholder strings ("N/A", "TBD", "—") with actual empty cells. Replace inconsistent spelling variants ("color" vs "colour") with one canonical form.

Converting between data formats. A list of items with semicolon delimiters needs to become comma-delimited. A markdown bullet list needs to become a numbered list. Find-and-replace handles the structural transformation when it's just one substitution.

Removing or replacing patterns. Strip all timestamps from a log file using a regex pattern. Remove all parenthesized comments from a document. Replace every URL with [link]. These need regex, not plain matching.

Inserting consistent text across a document. Replace every instance of a placeholder ("[CLIENT_NAME]") with a real value, throughout a contract or proposal. Faster than scanning manually for placeholders.

Removing diacritics or smart quotes. Replace specific characters with their plain equivalents. Smart quotes ("/") to straight ("/"), em dashes (—) to hyphens (-), accented letters to plain (é → e, though full transliteration needs more sophisticated tooling).

Building or fixing markdown links. Replace bare URLs with markdown link syntax using regex backreferences. Replace one link target with another across all references.

Plain mode vs regex mode

Plain mode treats your search string as literal text. find: "." matches only actual periods. find: "(name)" matches the literal four characters including the parentheses. This is what most people want most of the time.

Regex mode treats your search string as a regular expression. find: "." matches any single character (a regex special character). find: "(name)" creates a capture group that matches "name" and remembers what was captured for use in replacement. This is enormously more powerful but requires you to know regex syntax.

Common regex patterns that come up in find-and-replace work:

\d+ — one or more digits
\w+ — one or more word characters (letters, digits, underscores)
\s+ — one or more whitespace characters
^ — start of line
$ — end of line
(...) — capture group
$1, $2 — backreferences in the replacement string

For example, to swap "FirstName LastName" to "LastName, FirstName" everywhere in a document: regex (\w+) (\w+), replacement $2, $1.

Case sensitivity and whole word matching

Case-sensitive (default). "foo" matches "foo" but not "FOO" or "Foo". The right choice when case carries meaning — code identifiers, brand names, log entries with case-significant IDs.

Case-insensitive. "foo" matches all of "foo", "FOO", "Foo", "fOo". The right choice for natural language search where capitalization is incidental.

Whole word matching. "form" matches "form" as a word but not as a substring of "format" or "platform". Implemented via word boundary anchors (\b in regex). The right choice when you need to find a specific word, not any string that happens to contain those letters.

Whole-word matching combined with case-insensitive matching catches "Form", "FORM", and "form" as standalone words while ignoring "format", "Platform", and "FORMAT" — which is usually exactly what you want when bulk-replacing terms.

Common pitfalls

Forgetting to escape special characters in plain mode. Wait, this only applies in regex mode. In plain mode, every character is literal. So if you're trying to find "100$" and replacing in regex mode, the dollar sign is a regex anchor and won't match. Switch to plain mode or escape it as \$.

Replacing inside other words. Without whole-word matching, "cat" matches inside "category", "concatenate", "scatterplot", and dozens of others. Always use whole-word matching for word-level replacements.

Smart quotes producing zero matches. If your document has been through Word, the quotes are curly (", "). Searching for straight quotes (") produces zero matches. Either copy a curly quote from your document into the search field, or normalize quotes through a separate pass first.

Greedy regex matching. The regex (.*) is greedy — it matches as much as possible. To find the shortest match, use (.*?). This trips up people who write <a (.*)> expecting it to match a single tag and discover it matches everything between the first <a and the last > on the line.

Replacing without preview. A regex that's almost right can produce surprising results across thousands of replacements. Test on a small sample first, verify the output, then run on the full text.

Find & Replace vs sed vs the Word Find dialog

This tool — fastest for one-off transformations on text in a browser, regex available, no install. Best for ad-hoc cleanup.

sedsed 's/find/replace/g' file.txt. Best for very large files, scripted workflows, automation. The regex flavor is slightly different (BRE/ERE rather than ECMAScript), so patterns don't always transfer one-to-one.

Microsoft Word's Find and Replace (Ctrl+H) — best when you're already in Word and need formatting-aware replacement (replace bold text, replace specific paragraph styles). Limited regex support; better for simple text replacement.

Code editor find-and-replace (VS Code, IntelliJ, etc.) — best when you're already in a code editor and the text is in files. Multi-file replacement, project-wide search, regex with capture groups.

How the tool works

Paste your text in the input box. Type the find string and the replace string. Click Replace All. The tool uses JavaScript's String.prototype.replace with global flag for plain mode, and RegExp-based replacement for regex mode. The i flag is added when case-insensitive is selected; word boundaries are added to the pattern when whole-word matching is selected.

Both inputs and output remain in your browser. No network requests; no data leaves your computer.

The tool also reports a count of replacements made, so you can sanity-check that the operation found what you expected.

Workflow tips

Always check the count. If you expected 50 replacements and got 200, something is matching that shouldn't (probably partial-word matches when you needed whole-word). If you expected 50 and got 0, your search isn't finding what you thought (probably case sensitivity or smart quotes).

Preview with regex highlighting first. Some tools show what will be matched before you commit to replacement. This tool doesn't currently, so build confidence on a small sample before processing a large document.

Use plain mode by default; switch to regex when needed. Regex is powerful but error-prone. If your replacement is a literal string-for-string swap, plain mode is faster and safer.

Chain operations rather than building one giant regex. Instead of one regex that does five things, do five operations in sequence. Easier to debug, easier to verify each step.

Frequently asked questions

Does it support regex?

Yes. Toggle the regex mode option to interpret your search string as a JavaScript regular expression. Backreferences in the replacement string use $1, $2, etc.

Will it replace all occurrences or just the first?

All occurrences. The tool always operates globally; "replace first only" requires manual editing.

Is it case-sensitive by default?

Yes. Toggle the case-insensitive option for case-blind matching.

What about multi-line patterns in regex?

The regex flag is set so . doesn't match newlines (default JavaScript behavior). To match across lines, use the explicit pattern [\s\S] instead of ., or look for pattern-spanning content with the multiline flag implicitly applied via the tool's settings.

Can I use this for case conversion?

Use the dedicated Case Converter for that — it's faster and handles edge cases better. Find-and-replace can do case conversion via regex with backreferences, but it's clunky.

Does it preserve undo history?

The tool does a single-step transformation. Once you click Replace All, the new state is in the box. Browser-level undo (Ctrl+Z in the textarea) sometimes works for the input but not the output. For multi-step operations where undo matters, work in stages and copy each intermediate result.

Related

Advertisement

Learn more about find and replace