Find and Replace

Find text and replace it everywhere, with match case, whole words and regular expressions with capture groups.

The cat sat on the mat. Cats are curious; the cat next door is called Tom.

How it works

Type what to find and what to put in its place, and the replaced text appears as you type. Every match is highlighted in the preview below the boxes, with a count, so you can see exactly what will change before you copy anything.

By default the search is a plain, case-insensitive text match: whatever you type is found literally, including characters such as dots, dollar signs and brackets. Three options narrow or widen what counts as a match, and a fourth decides whether every match is replaced or only the first.

What each option changes

The tool opens with a two-sentence sample: The cat sat on the mat. Cats are curious; the cat next door is called Tom. Searching for cat and replacing it with dog gives these real results:

OptionsMatchesResult
Default3The dog sat on the mat. dogs are curious; the dog next door is called Tom.
Match case2The dog sat on the mat. Cats are curious; the dog next door is called Tom.
Whole words only2The dog sat on the mat. Cats are curious; the dog next door is called Tom.
Replace first only3 (1 replaced)The dog sat on the mat. Cats are curious; the cat next door is called Tom.

The default result shows the classic find-and-replace trap: Cats became dogs, with a lowercase d, because the search ignored case and the match was the first three letters of a longer word. Both Match case and Whole words only avoid it here, for different reasons. Match case skips Cat because of the capital; whole words skips it because it is part of Cats.

The two options are not the same. Searching for the with whole words on finds three matches, including the capitalized The at the start; add match case and it finds two, leaving The alone. Whole words treats letters, digits and underscores as word characters, accented letters included, so cafe with an accent matches on its own but not inside cafes.

Check the count before you copy. If the number of matches is higher than you expected, a short search term is probably matching inside longer words. Turn on Whole words only, or make the search more specific.

Regular expressions and capture groups

Tick Regular expression and the Find box accepts a JavaScript regular expression, the pattern language used by most programming languages and code editors. A pattern describes a shape of text rather than fixed characters: \d is any digit, \w+ is a run of word characters, {4} means exactly four of the previous item.

Parentheses create capture groups, and the replacement can refer back to them with $1, $2 and so on. That turns find and replace into a rearranging tool:

TextFindReplace withResult
Smith, John / Doe, Jane(\w+), (\w+)$2 $1John Smith / Jane Doe
Due 2026-03-15, paid 2026-04-02.(\d{4})-(\d{2})-(\d{2})$2/$3/$1Due 03/15/2026, paid 04/02/2026.
Due 2026-03-15, paid 2026-04-02.(\d{4})-(\d{2})-(\d{2})$3/$2/$1Due 15/03/2026, paid 02/04/2026.
one  two   three {2,}a single spaceone two three
Call 555-0100 or 555-0199.\d{3}-\d{4}[$&]Call [555-0100] or [555-0199].

A slash in the Text column marks a line break. Each pattern found two matches.

The date rows convert ISO dates to the US month/day/year order and the UK and European day/month/year order with nothing more than a change of replacement. In the last row, $& stands for the whole match, which is useful for wrapping matches in brackets or quotes. Use $$ for a literal dollar sign and $<name> for a named group written as (?<name>...).

Special characters when regex is off

With Regular expression off, nothing in the search has a special meaning. Finding $5.00 in Price: $5.00 (approx.) and replacing it with $6.50 makes one replacement, and the replacement is inserted exactly as typed. Tick Regular expression and the same search finds nothing, because $ means end of line and . means any character. Likewise, finding a single dot in a.b.c replaces two dots in plain mode but all five characters in regex mode.

When a pattern is invalid

An unfinished pattern such as (abc or [a- cannot be run. Instead of guessing, the tool shows a message under the options naming the problem, for example an unterminated group, and leaves the output empty until the pattern is fixed. Your text is never changed by a broken pattern.

Practical recipes

  • Delete something everywhere: leave Replace with empty. Every match is removed.
  • Collapse repeated spaces: regex {2,}, replace with one space.
  • Remove trailing spaces: regex [ \t]+$ with an empty replacement. Regex mode is multiline, as in most code editors, so ^ and $ match at the start and end of every line, not just the whole text. On alpha, beta, gamma with spaces after the first two lines, this makes two replacements.
  • Turn lines into a bulleted list: regex ^, replace with a hyphen and a space. Three lines give three matches: - alpha, - beta, - gamma.
  • Rename a variable in code: plain search with Match case and Whole words only, so count does not change counter or Count.
  • Swap two words: regex (first) (second), replace with $2 $1.

Regular expressions here follow JavaScript rules. Most patterns written for other languages work unchanged; inline flags such as (?i) are not supported, so use the Match case checkbox instead.

Privacy

Everything happens in your browser. Your text and patterns are processed on your own device. Nothing is uploaded, stored or logged, so you can safely edit contracts, code or private notes. Closing the tab discards everything.

Frequently Asked Questions

How do I find and replace text online?

Paste your text, type the word or phrase in Find and the new text in Replace with. The replaced text appears instantly on the right, with every match highlighted below and a count. Click Copy to take the result.

How do I replace only whole words?

Tick Whole words only. A match must then start and end at a word boundary, so cat matches cat but not Cats or concatenate. Letters, digits and underscores count as word characters.

How do I use capture groups like $1?

Tick Regular expression, wrap parts of the pattern in parentheses, and refer to them in the replacement as $1, $2 and so on. For example, find (\w+), (\w+) and replace with $2 $1 to turn Smith, John into John Smith.

Why does my regular expression show an error?

The pattern is incomplete or uses syntax JavaScript does not accept, such as an unclosed bracket or parenthesis. The message names the problem. Fix the pattern and the result appears; your text is not changed in the meantime.

How do I search for a dot, dollar sign or bracket?

Leave Regular expression off and type it normally; every character is matched literally. In regex mode, put a backslash in front of it, for example \. for a literal dot.

How do I delete every occurrence of a word?

Type the word in Find and leave Replace with empty. Every match is removed. You may want to include the space after the word in the search so you do not leave double spaces behind.

Can I replace only the first match?

Yes. Click Replace first only. The count still shows how many matches exist in total, so you can see how many were left unchanged.

Is the search case-sensitive?

Not by default: cat also finds Cat and CAT. Tick Match case to find only the exact capitalization you typed.

Is my text uploaded anywhere?

No. The search and replacement run entirely in your browser and nothing is sent to a server.

Related Calculators