TanodTools

Find and replace text

Replace words or patterns across a block of text, and see how many matches there are before you replace.

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 $ 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. In literal mode, letters, digits and underscore count as word characters in any script. In regular-expression mode it wraps your pattern in word boundaries (\b), which only recognise A-Z, digits and underscore.

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.

Does the pattern run across lines?

In regular-expression mode ^ and $ match at the start and end of every line, and the dot does not match a line break. Case is ignored unless Match case is on.

Is my text uploaded?

No. Everything runs in your browser and nothing is stored or sent.