go-supertools
Text Tools

Text Replacer

Replace text in subject.

Runs in your browser Your input never leaves your device.

0 characters | 0 words

Report a problem with this tool

About this tool

This tool replaces every match of a search term in your text with new text. Type what to find and what to replace it with, and the result updates as you type. By default the search is plain text and case-sensitive. Tick Ignore case to match any capitalization, or tick Regex to use a JavaScript regular expression, in which case group references such as $1 can be used in the replacement. If the regular expression is invalid, the output shows a warning with the error message instead of your text. Every occurrence is replaced. Leave the replacement empty to delete matches. All processing happens in your browser.

How to use it

  1. Paste your text into the input box.
  2. Type the text to find in Find, and the new text in Replace with.
  3. Tick Regex or Ignore case if you need them.
  4. Press Copy to take the result.

Example

Find is cat, Replace with is dog, Ignore case ticked.

Input
Cat cat CAT
Result
dog dog dog

Replacing whole words only

In plain mode the search matches inside words too, so replacing cat with dog also turns category into dogegory.

To match whole words only, tick Regex and wrap the word in \b markers, for example \bcat\b. The \b means a word boundary, so cat and cat. match but category does not. Tick Ignore case to match Cat as well.

Regex recipes

Tick Regex, then use these in Find and Replace with.

Collapse repeated spaces
Find: a space followed by {2,}, Replace with: a single space.
Line breaks to commas
Find: \r?\n, Replace with: a comma and a space. This joins a list of lines into one line.
Swap two words
Find: (\w+), (\w+), Replace with: $2 $1. Smith, John becomes John Smith.
Wrap each number
Find: \d+, Replace with: [$&]. $& inserts the whole match, so 42 becomes [42].
Remove blank lines
Find: (\n)\s*\n, Replace with: $1. Each run of blank lines becomes a single line break.

Special characters in the replacement

The Replace with field follows JavaScript replacement rules, even with Regex off. $& inserts the matched text, $1, $2 and so on insert regex groups, and $$ inserts a single dollar sign.

Typing a newline into Replace with is not possible in a one-line field. To add line breaks, use a group that captured one, as in the blank lines recipe above.

Common problems

A warning appears instead of the text
With Regex on, the pattern is not a valid regular expression, for example an unclosed parenthesis. Fix the pattern, or turn Regex off to search for the characters literally.
Special characters match unexpectedly
With Regex on, characters such as . ( ) and * have special meaning. Turn Regex off to search for them literally.
Empty Find field
If Find is empty, the text is returned unchanged.

Frequently asked questions

Can I make several different replacements at once?

Not in one pass. The tool handles one Find and Replace with pair. Copy the result back into the input and run the next replacement.

How do I put a dollar sign in the replacement?

Type $$ for one $. A $ followed by &, a backtick or an apostrophe is read as a special pattern, and so is $1 when the regex has a first group.

Is my text uploaded?

No. The replacement runs in your browser, and regex patterns run in a background worker on your device with a short time limit so a slow pattern cannot freeze the page.