Skip to main content
CalcChef

Text Replacement

Find and replace text in a pasted block, as plain text or regex, with a case option. Replace All gives the result and the number of replacements made. How it works

Use the Text Replacement

About the Text Replacement

Replacing “cat” with “dog” in “cat concat cat” gives “dog condog dog”: plain text matches inside words, and every match is replaced. Type Find, Replace With and the text, then press Replace All. Tick Whole words only to get “dog concat dog” instead, Use Regex for patterns and Case Insensitive to ignore capitals. The result clears as soon as you change any input.

Codes you can type in Replace With

Replace WithInsertsFind, and textResult
[$&]the matched texta in xazx[a]z
[$`]the text before the matcha in xazx[x]z
[$']the text after the matcha in xazx[z]z
$$a dollar signa in xazx$z
$1nothing special in plain mode: stays as typeda in ab$1b
$2$1capture groups 2 and 1 (Use Regex on)(a)(b) in abba

The same rules as String.prototype.replace in JavaScript. In plain mode the Find text has no capture groups, so $1 is left as typed.

Regex examples (Use Regex on)

FindReplace WithOriginal TextResult
[0-9]+#a1b22a#b#
([0-9]+)-([0-9]+)-([0-9]+)$3/$2/$12026-10-1414/10/2026
(\w+) (\w+)$2, $1Jane SmithSmith, Jane
\s+_a b ca_b_c
a\.bxa.b.cx.c
.xa😀bxxxx

The last row shows regex mode working on UTF-16 code units: the emoji is two units, so a 3-character text gives 4 matches. Plain text, with 😀 as Find, replaces the emoji whole.

How to use this tool

  1. Paste or type the text in Original Text.
  2. Type what to look for in Find and its replacement in Replace With.
  3. Tick Whole words only to skip matches inside longer words, Use Regex to treat Find as a pattern, and Case Insensitive to ignore capitals.
  4. Press Replace All, then use the copy button on the Result.

Frequently asked questions

How do I find and replace text online?
Paste the text in Original Text, type Find and Replace With, and press Replace All. Nothing changes while you type; the result appears when you press the button. To replace cat with dog in “cat concat cat”, the result is “dog condog dog”.
Does it replace every match or only the first?
Every match, and the page says how many: “cat concat cat” gives 3 replacements made. Matching is case sensitive by default, so “Cat cat CAT” with cat replaced by dog gives “Cat dog CAT”. With Case Insensitive ticked it gives “dog dog dog”. Plain text also matches inside words, so cat in “cat concat cat” gives “dog condog dog”; tick Whole words only and it gives “dog concat dog”. A whole-word match cannot touch a letter, digit or underscore where the Find text starts or ends with one, so c++ still matches in “c++ code”. With Use Regex on, write \b in the pattern instead.
How do I use regex to find and replace?
Tick Use Regex and write a JavaScript pattern in Find. Parentheses make capture groups that Replace With can reuse as $1, $2 and so on: (\w+) (\w+) with $2, $1 turns “Jane Smith” into “Smith, Jane”. An invalid pattern shows its error under the Find field.
Why did my result disappear?
The result belongs to the inputs it was made from. When the text, Find, Replace With or any checkbox changes, the result is cleared and the page says the inputs changed, so what you see is never out of date. Press Replace All again.
Why does a dot match only half of an emoji in regex mode?
Regex mode works on UTF-16 code units, and an emoji such as 😀 takes two of them. Replacing . with x in “a😀b” gives “xxxx”. Use plain text for emoji: 😀 replaced by [X] in the same text gives “a[X]b”.
Can it add or remove text at the start of every line?
Not with ^: the tool has no multiline option, so ^ matches only the start of the whole text, and replacing ^ with “> ” puts it once, at the very beginning. The Regex Tester has the m flag and a replace mode, so ^ there matches every line start. To remove a prefix that never appears elsewhere, plain mode works: replace it with nothing.

Related Tools

View all tools