Text tools

Find and replace text

Paste some text, type what to find and what to put in its place, and see every match highlighted before you commit. Plain text mode is literal and safe; regular expression mode handles patterns such as phone numbers, dates and runs of blank lines, with group references like $1 in the replacement.

Runs entirely in your browser. Nothing you enter here is uploaded.

How to find and replace

  1. Paste your text into the Text box.
  2. Type what to look for in Find. Every match is highlighted in the preview below, with a count.
  3. Type the new text in Replace with. Leave it empty to delete the matches.
  4. Choose options: Match case to treat A and a as different, Whole words only so that "cat" does not match inside "catalog", Understand \n and \t to search for or insert line breaks and tabs, and Regular expression for patterns.
  5. Press Replace all to apply the change to the text, or Copy result to copy the changed text without touching the original. Undo steps back through your replacements.

How matching works

Plain text mode

In the default mode, both boxes are taken literally. A full stop matches a full stop, and a $ in the replacement is a dollar sign. This is the safe choice for ordinary edits such as renaming a product or fixing a repeated typo. Matches never overlap: replacing "aa" in "aaa" changes the first two letters and leaves the third.

Regular expressions

Regular expression mode uses the JavaScript syntax described on MDN. All matches are replaced, ^ and $ match at the start and end of every line, and the pattern works on whole Unicode characters, so an emoji counts as one character rather than two halves. In the replacement, special patterns insert parts of the match: $& is the whole match, $1 to $99 are numbered groups and $<name> is a named group written as (?<name>…).

Whole words

Many tools implement "whole word" with \b, which only knows the letters A to Z, so café is treated as ending in the middle of the word. This tool instead checks that the characters on either side are not letters, digits or underscores in any script. Chinese and Japanese are written without spaces, so whole-word matching has no useful meaning for them.

Runaway patterns

Some patterns, such as (a+)+$, can take exponentially long on text that almost matches — the problem known as catastrophic backtracking or ReDoS. The search runs in a separate background thread and is stopped after two seconds, so a bad pattern cannot freeze the page.

Examples

TaskFindReplace withResult
Reorder a date(\d+)-(\d+)-(\d+) (regex)$3/$2/$12026-09-28 → 28/09/2026
Swap names(?<first>\w+) (?<last>\w+) (regex)$<last>, $<first>John Smith → Smith, John
Wrap numbers\d+ (regex)[$&]a1b22 → a[1]b[22]
Collapse spaces\s+ (regex)a single spaceone two three → one two three
Remove blank lines\n{2,} (regex)\n (escapes on)three line breaks become one
Quote every line^ (regex)> every line starts with >
Comma list to lines, (escapes on)\na,b,c → one item per line

In plain text mode, replacing $5 with $10 in "price $5" gives "price $10" — the dollar signs are not treated as group references. With Whole words only, replacing cat with dog in "cat catalog concat" changes only the first word.

Limits

  • JavaScript regular expressions only. Syntax from other engines, such as possessive quantifiers or \A and \Z from PCRE, is not supported. Lookbehind, named groups and Unicode property escapes such as \p{L} are supported.
  • The preview shows the first 20,000 characters and highlights up to 5,000 matches. The count and the replacement always cover the whole text.
  • Undo lasts until you edit the text by hand. Typing in the text box starts a new history.

Frequently asked questions

How do I replace text with a line break?

Turn on "Understand \n and \t" and type \n in the replacement box.

Why does "." match every character?

You are in regular expression mode, where . means "any character". Turn it off, or write \. to match a literal full stop.

How do I use the matched text in the replacement?

In regular expression mode, $& is the whole match and $1, $2… are the parts in parentheses.

Can I delete every match?

Yes. Leave the replacement empty and press Replace all.

Is my text uploaded?

No. Matching runs in a background thread of your own browser.

Sources and further reading

↵ to open · Esc to close