Format Code Now
/
TextText Replacer Next: Word Repeater ›

Text Replacer

TX-59

Replace several words or phrases in one pass. List each pair as a -- find: line and a -- replace: line, put your text below, and press Replace. Whole-word, case and regular expression options are available.

Runs in your browser. Nothing is uploaded.

Pairs of -- find: and -- replace: lines, then your text

Replaced text

How to use it

  1. Write the first pair: a line -- find: colour, then a line -- replace: color.
  2. Add more pairs the same way, each starting with its own -- find: line.
  3. Paste the text to change below the pairs.
  4. Set the options if you need whole words, case-insensitive matching or regular expressions, then press Replace. Press Count replacements to see how many matches each pair made.

How pairs are applied

Every line that starts with -- find: opens a new pair, and an optional -- replace: line right after it sets what to put there. With no replace line, the match is deleted. The pairs run in order on the text below, so a later pair sees the result of an earlier one: replacing a with b and then b with c changes the original a to c as well. One space after the colon is dropped, and any other spaces belong to the value.

Plain, whole-word and regular expression modes

In plain mode the find text is matched literally, so dots and brackets mean themselves and the replacement is inserted as typed. Whole words only requires letters, digits or underscores not to touch the match on either side. In regular expression mode the find text uses JavaScript syntax and the replacement can use $1 for a group and $& for the whole match. An invalid pattern stops with an error that names the problem. Tick the escapes option to type a line break as \n and a tab as \t.

Counting and checking

Count replacements runs the same pairs but reports how many matches each pair found and the total, without showing the changed text, so you can check a pair before you rely on it. It reports each pair after the earlier ones have been applied, so the counts match what Replace does. For a single find and replace with a plain layout, the Find and Replace tool does the same job with one pair.

Error messages and what to do

MessageWhat it meansFix
Add a line that starts with "-- find:" before your text.The first line is not a find directive.Start with a line such as -- find: colour, then optionally -- replace: color.
Put the text to change below the directive lines.There are find and replace lines but no text under them.Paste the text to change under the last directive line.

Questions people ask

How do I replace multiple words in text at once?

Write a -- find: line and a -- replace: line for each pair, one pair after another, paste your text below and press Replace. All pairs are applied in order in one pass.

How do I delete a word instead of replacing it?

Write the -- find: line and leave out the -- replace: line, or leave its value empty. Every match of that find text is then removed from the text instead of being swapped for something else.

Can I use regular expressions?

Yes. Tick Find is a regular expression, write the pattern after -- find: and use $1 for groups in the replacement. Invalid patterns give an error message.

How do I replace whole words only?

Tick Whole words only. A match counts only when no letter, digit or underscore touches it on either side, so replacing cat changes the word cat but does not change category or concatenate.

Do later pairs see the changes made by earlier pairs?

Yes. The pairs run in order on the same text. Put them in an order where this cannot cause a clash, or use a distinctive placeholder for swaps.

About this tool

Every line starting with -- find: opens a new pair and an optional -- replace: line right after it sets the replacement; with no replace line, the match is deleted. One space after the colon is dropped and any other spaces belong to the value. The pairs run one after another on the text below the directive lines, so a later pair sees the result of an earlier one. In plain mode the find text is matched literally and the replacement is inserted as typed. In regular expression mode the find text uses JavaScript syntax, and the replacement can use $1 for groups and $& for the whole match. Whole words use letters, digits and underscore as word characters. Count shows how many matches each pair made. An invalid pattern stops with an error. Nothing is uploaded.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.