T

Text Machine

Powerful text tools, in your browser

Find and Replace Text

Quickly find and replace words or patterns in your text.

Your Text
Find

Find

Replace with

Result

Matches Found: 0

Replacements Made: 0

How to use Find and Replace Text

  1. 1

    Paste your text

    Enter or paste the document or code you want to edit into the text area.

  2. 2

    Enter find and replace terms

    Type the word or pattern to search for in the Find box and what it should become in the Replace with box, which can be left empty to delete matches.

  3. 3

    Set matching options

    Turn on Case Sensitive, Whole Word Only, or Use Regular Expression to control exactly which occurrences are matched.

  4. 4

    Replace and copy

    Click Replace All to apply the changes, check the matches and replacements count, then copy the result.

Mastering Find and Replace: Literal, Whole-Word, and Regex

Three options that change everything

Find and replace looks simple, but the three checkboxes, Case Sensitive, Whole Word Only, and Use Regular Expression, are what turn it from a blunt instrument into a precision tool. The default is a literal, case-insensitive search that replaces every occurrence of your term. Each option narrows or expands which occurrences match, so picking the right combination is the whole skill.

After every run, the tool reports the number of matches found and replacements made. Treat that count as your safety check: if you expected to change five names and the counter says fifty, your search was too broad, and you can adjust an option before the change goes anywhere it shouldn't.

Literal search and case sensitivity

By default the search is literal, meaning it looks for the exact characters you type, and it ignores case, so "color" matches "Color" and "COLOR" alike. That is ideal for quick, forgiving cleanups where capitalization varies. Replacing "teh" with "the" across a document is the classic example.

Turn on Case Sensitive when capitalization carries meaning. Searching for "US" with case sensitivity on will match the country abbreviation but skip the word "us," and replacing "id" without case sensitivity could wreck "ID," "Id," and "hidden" alike. Whenever a term doubles as a common word, case sensitivity is your first line of defense.

Whole Word Only prevents collateral damage

The most common find-and-replace disaster is matching your term inside a larger word. Search for "cat" without protection and you will also hit "category," "scatter," and "vacate." Whole Word Only fixes this by matching your term only when it stands alone, bounded by spaces or punctuation rather than buried in another word.

Use it whenever you are replacing a short word or a name that could appear as a fragment elsewhere. Renaming a variable called "sum" to "total" is safe with Whole Word Only on; without it, you could silently corrupt "summary" and "consume." The match counter makes the difference obvious before you commit.

Unlocking regular expressions

Enable Use Regular Expression to search by pattern instead of by exact text. Regex lets you match classes of characters, repetition, and positions. A pattern like \d+ matches any run of digits, \s+ matches any run of whitespace, and the anchors ^ and $ match the start and end of a line. This is how you find things that vary, not just things that are fixed.

Practical wins include collapsing multiple spaces into one by replacing \s+ with a single space, or stripping trailing spaces by matching a whitespace run anchored to the end of the line. If your pattern has a syntax error, the tool warns you with an invalid-expression message so you can fix it rather than getting a silent wrong result.

Capture groups for reformatting

Regex truly shines when you need to rearrange text, not just delete it. Capture groups, written with parentheses, remember parts of the match so you can reuse them in the replacement using backreferences like $1 and $2. This lets one pass transform structured data into a new shape.

For example, to flip "Last, First" into "First Last," match the pattern that captures the two names around the comma and replace with the second group, a space, then the first group. The same technique reformats dates, swaps key-value pairs, and wraps matched text in new characters, all in a single Replace All.

Deleting text and ordering your edits

Leaving the Replace with field empty turns find-and-replace into a remover: every match simply disappears. This is the fast way to strip unwanted characters, delete boilerplate phrases, or remove formatting markers from pasted text. Combine it with regex to delete patterns, such as removing all digits or all bracketed notes at once.

When you run several replacements in sequence, order matters. An early replacement can create or destroy text that a later one depends on. Plan the sequence so each step leaves the text in the state the next step expects, and watch the replacement counts to confirm each pass did what you intended before moving on.

Common mistakes to avoid

The top three mistakes are predictable. First, replacing a short word without Whole Word Only and shredding longer words. Second, forgetting Case Sensitive and changing text you meant to leave alone. Third, in regex mode, forgetting that characters like the period, asterisk, plus, parentheses, and brackets are special, so a literal period must be escaped as \. to avoid matching every character.

The cure for all three is the same: make one change, read the match and replacement counts, and verify the result before chaining the next edit. Because everything runs locally in your browser, you can experiment freely on sensitive documents and code without anything being uploaded.

Frequently asked questions

Does it support regular expressions?
Yes. Enable Use Regular Expression to search with regex patterns, including capture groups, character classes, and anchors. If the pattern is invalid, the tool warns you so you can fix the syntax.
How does Whole Word Only work?
With Whole Word Only enabled, the tool only matches your term when it stands alone, so searching for cat will not change words like category or scatter.
Can I delete text instead of replacing it?
Yes. Leave the Replace with field empty and every match of your search term will simply be removed from the text when you click Replace All.
How do I know how many changes were made?
After each run the tool displays the number of matches found and replacements made, so you can confirm the edit affected exactly as much text as you expected.
Is my text kept private?
Yes. All find-and-replace processing happens locally in your browser and nothing is uploaded to a server, so it is safe for private documents and source code. The tool is free with no registration.

Related tools

Keep going with these handy tools

Case Converter

Bionic Reading

Capitalize First Letter

Capitalize Each Word

Title Capitalization Tool

Remove Extra Whitespaces