Skip to content
GivenTool

Find and replace text

Find and replace text, as plain text or with regular expressions (capture groups, flags), with a count of replacements.

0 / 2,000,000 characters · Updates as you type.

Settings

Leave empty to delete matches. In regex mode, $1 and $<name> insert captured groups and $& the whole match.

Runs in your browser. Nothing you type is sent anywhere.

Paste text, type what to find and what to replace it with, and the result updates as you type, with the number of replacements made. Plain-text mode finds the exact characters you type (dots, brackets and dollar signs included) and inserts the replacement literally. Options restrict matches to whole words (Unicode-aware, so it works for accented and Arabic words too) and control case sensitivity and whether every match or only the first is replaced.

Regular-expression mode uses JavaScript regex syntax with Unicode enabled: \d, \s, \p{L} for any letter, lookarounds, and named groups. In the replacement, $1 or $<name> inserts a captured group and $& the whole match, so find (\w+)@(\w+) and replace with $2 at $1 swaps parts of an address. The m and s flags are available as options.

A badly written pattern can take exponential time on some inputs (catastrophic backtracking). Like the regex tester on this site, regex replacements run in a Web Worker that is stopped after 2 seconds, so the page never freezes. The text never leaves your browser.

How to use it

  1. Paste the text to edit into the box.
  2. Type the text or pattern to find and its replacement; choose plain text or regular expression.
  3. Set match case, whole words and replace-all as needed; the result and the replacement count update live.
  4. Copy the result or download it as a .txt file.

Frequently asked questions

How do I delete every occurrence of a word?

Type the word in Find, leave Replace with empty, and keep "Replace all" on. Turn on "Whole words only" so that, for example, "cat" does not remove the start of "catalogue".

How do I use capture groups?

Switch to regular expression mode, wrap parts of the pattern in parentheses, and refer to them as $1, $2 ... in the replacement. Named groups (?<year>\d{4}) are inserted with $<year>.

Can I insert a line break in the replacement?

The replacement field is a single line, so to join or split lines use a regex that matches the line break (\n) in Find instead.

Why did my pattern stop with a timeout?

It probably has nested quantifiers such as (a+)+ that backtrack exponentially. Simplify the pattern; the 2-second limit protects the page.