ToolLineup

Find and Replace Text

This find and replace tool rewrites every occurrence in a block of text at once. The search is literal by default, which matters more than it sounds: a full stop means a full stop rather than any character, so replacing a full stop actually replaces full stops. Switch to regular expressions when you do want pattern matching, and the replacement can then refer back to captured groups with $1, $2 and $&. Whole-word matching stops cat from also changing category, case matching is optional, and a backslash n or backslash t in the replacement inserts a real newline or tab. The number of replacements made is reported so you can sanity-check the result.

How it works

Finds and replaces across the whole text at once. By default the search is literal, so a full stop means a full stop rather than "any character" — turn on regular expressions when you want pattern matching.

In regex mode the replacement can refer back to captured groups with $1, $2 and so on, and $& stands for the whole match. In literal mode a dollar sign is just a dollar sign. \n and \t in the replacement always insert a newline or tab.

Everything runs in your browser — nothing you paste is sent to a server.

Text input
Paste or type your text here…
Result

0 replacements made.

Literal versus regular expression

Most find-and-replace bugs come from a tool treating the search as a pattern when the user meant it literally. Searching for . in pattern mode matches every character in the document and replaces the lot.

Here the search is literal unless you say otherwise. Special characters are escaped for you, so (, $, * and ? all mean themselves. Turn on regular expressions only when you want their pattern meaning.

Backreferences

In regex mode, parentheses capture part of the match and the replacement can put it back. Turning John Smith into Smith, John is:

Find:    (\w+) (\w+)
Replace: $2, $1

In literal mode $1 is written out as the characters $1, because a literal search has no groups to refer back to.

Whole words

Replacing id with identifier across a file will also rewrite width, valid and idle. Whole-word matching requires a word boundary on each side, which is almost always what you want when renaming a term.

Frequently asked questions

How do I find and replace text?

Paste your text into the left panel, type what to find and what to replace it with, and the result appears on the right immediately with a count of the replacements made.

Is the search literal or a pattern?

Literal by default, so special characters like . * and ? mean themselves. Tick Regular expression to switch to pattern matching.

How do I use captured groups?

In regex mode, wrap part of the pattern in parentheses and refer to it as $1, $2 and so on in the replacement. $& stands for the whole match. In literal mode a dollar sign is just a dollar sign.

How do I insert a newline?

Type a backslash followed by n in the replacement field. Backslash t inserts a tab. This works in both literal and regex mode.

What does whole words only do?

It requires a word boundary either side of the match, so searching for cat changes cat but leaves category and concatenate alone.

Is my text uploaded?

No. The replacement happens entirely in your browser.

Related tools