TanodTools
EN

Find and replace text

Find and replace literal text or JavaScript regex matches locally. Patterns that run too long are stopped.

Runs entirely in your browser

Type what to find.

Text up to about 5 MB. Regex patterns that run longer than 2 seconds are stopped.

How to find and replace text

  1. Paste your text into the box, or open a .txt file.
  2. Type what to find and what to replace it with. The number of matches updates as you type.
  3. Press Replace all, then copy the result or download it.

Replacing text in bulk

Find and replace changes every occurrence of a word or pattern in one pass. The match count updates while you type, so you can see how far a change reaches before you apply it, and the result appears in a separate box so your original text is never overwritten until you choose "Use result as text".

Regular expressions let you describe a shape rather than a fixed string: a run of digits, a date, a word followed by a comma. Groups in brackets can be rearranged in the replacement with $1, $2 and so on. Because a badly written pattern can run for a very long time, patterns are executed in a background worker that is stopped after two seconds.

Tips

Questions

Is the search literal or a pattern?

Literal by default: what you type is matched exactly, including characters like . and *. Turn on "Regular expression" to use JavaScript regular-expression syntax.

How do I use groups in the replacement?

In regular-expression mode, $1, $2 and so on insert the text matched by the first, second (and so on) bracketed group, $& inserts the whole match and $<name> inserts a named group. For example, finding (\w+)@(\w+) and replacing with $2 at $1 turns bob@example into example at bob. In literal mode the replacement is inserted exactly as typed.

What does Whole word do?

It only matches the search text when it is not part of a longer word, so finding cat does not match category. Letters, accents, digits and underscore count as word characters in any script, in both modes. In regular-expression mode, Whole word also turns on JavaScript's stricter Unicode syntax, so write - and \{ rather than \- and a bare {.

What is the 2-second limit?

Some patterns, such as (a+)+$, can take an extremely long time on certain text. Regular-expression mode runs in a separate background worker; if it has not finished after 2 seconds it is stopped and you are told the pattern took too long, so the page never freezes.