Text Tools

Find and Replace Guide: Plain Text, Whole Words and Regex Patterns

By Smart Tools Utility Team · Published October 7, 2026 · Updated October 7, 2026 · 9 min read

Find and replace is the quickest way to apply the same edit to a long text: rename a product, fix a recurring typo, reformat dates, strip stray characters. Our Find and Replace Tool does this in the browser, with three options (case sensitive, whole word, regular expressions) and a live match count. This guide covers each option, a set of tested regex recipes, and the behaviours that catch people out, including a few where the tool differs from what you may expect from a code editor.

Every input and result in this guide was produced by running the page, and the results are quoted exactly. In the examples, \n in a quoted string means a line break in the text.

How to use it

  1. Paste your text into Your text.
  2. Type what to look for in Find. A line under the options shows N match(es) found and updates a moment after each change.
  3. Type the replacement in Replace with. Leave it empty to delete the matches.
  4. Choose options: Case sensitive, Whole word only, Use Regex.
  5. Click Replace All. Every match is replaced at once.
  6. Copy Result or Download .txt (the file is named result.txt).
The Find and Replace Tool with three ISO dates in the text box, a regex with three capture groups in Find, $3/$2/$1 in Replace with, Use Regex ticked and 3 matches found
Before: the pattern matches all three dates and the count shows 3 matches.
The same page after clicking Replace All, with the dates now written day, month, year and a count of 0 matches
After Replace All: the dates read 15/03/2024, 14/04/2024 and 02/04/2024, and the count falls to 0.

Two things to know before you start. First, Replace All changes the text box itself. There is no separate output and no undo button; pressing Ctrl+Z after a replacement did not bring the old text back in our test. Keep a copy of the original until you have checked the result. Second, the match count is the quickest safety check: if you expected 12 changes and it says 112, stop and look at your pattern.

Plain text mode and special characters

With Use Regex off, whatever you type in Find is treated as ordinary text, so characters that have a meaning in regular expressions are safe. These all worked as literal text:

find $5.00  in  "Price: $5.00 (approx.) [a] a.b a+b *x*"   ->  1 match
find a.b    in  "a.b axb a.b"                               ->  2 matches (axb is not matched)
find (x)    in  "f(x) + g(x)"                               ->  2 matches
find \      in  "C:\Users\me"   replace /                   ->  C:/Users/me
find C++    in  "I like C++ and C#"  replace Rust           ->  I like Rust and C#

By default matching is not case sensitive: cat matches Cat and CAT. Tick Case sensitive to match exact capitalisation. On the sample The cat sat. The Cat ran. category cat., replacing cat with dog gave:

default:            The dog sat. The dog ran. dogegory dog.     (4 matches)
Case sensitive:     The dog sat. The Cat ran. dogegory dog.     (3 matches)
Whole word only:    The dog sat. The dog ran. category dog.     (3 matches)
Both:               The dog sat. The Cat ran. category dog.     (2 matches)

The first row shows why the next option exists: category became dogegory.

Whole word only: where it works and where it does not

The option wraps your search in a word-boundary check, so cat no longer matches inside category. It is based on plain English letters, digits and underscores, which gives three kinds of surprise:

Regular expressions

Tick Use Regex and the Find field is read as a JavaScript regular expression, matched across the whole text with the global flag (all matches) and, unless Case sensitive is ticked, the case-insensitive flag. Common building blocks work as you would expect: \d, \w, \s, character classes, ?, +, *, {n,m}, groups, lookahead such as foo(?=\d) and lookbehind such as (?<=price )\d.

If the pattern is not valid, a red message appears and nothing is replaced. The messages come from the browser, and the tool adds its own prefix, so the wording is repeated:

(abc   ->  Invalid regular expression: Invalid regular expression: /(abc/gi: Unterminated group
*abc   ->  Invalid regular expression: Invalid regular expression: /*abc/gi: Nothing to repeat
[a-    ->  Invalid regular expression: Invalid regular expression: /[a-/gi: Unterminated character class

The message shows the pattern with its flags (gi), which is a quick way to confirm which flags are active. An empty Find field gives Please enter something in the "Find" field. when you click Replace All.

Capture groups and $ references

Wrap part of the pattern in brackets to capture it, then reuse it in Replace with as $1, $2, and so on. The screenshots above use this to turn year-month-day dates into day/month/year:

Find:     (\d{4})-(\d{2})-(\d{2})
Replace:  $3/$2/$1
Text:     Date: 2024-03-15 and 2025-12-01
Result:   Date: 15/03/2024 and 01/12/2025

More tested recipes (all with Use Regex ticked):

Swap "Last, First":   (\w+), (\w+)  ->  $2 $1        Smith, John  =>  John Smith
Named groups:         (?<first>\w+) (?<last>\w+)  ->  $<last>, $<first>     John Smith  =>  Smith, John
Mask an email name:   (\w+)@([\w.]+)  ->  ***@$2    bob@example.com  =>  ***@example.com
Collapse spaces:      \s{2,}  ->  (one space)        a    b   c  =>  a b c
Remove digits:        \d+  ->  (empty)               a1b22c333  =>  abc
Optional letter:      colou?r  ->  hue               color colour  =>  hue hue
Add a dollar sign:    (\d+)  ->  $$$1                cost 5 and 10  =>  cost $5 and $10

The dollar sign in the replacement, even with regex off

The replacement text is interpreted by JavaScript's replace rules even when Use Regex is off. Some $ combinations therefore do not come out literally:

To write a literal dollar sign immediately before a digit or & in the replacement, double it: $$.

Mistakes and limits that cost time

Greedy matching takes too much

.* matches as much as it can. On <b>one</b> and <b>two</b>, the pattern <b>.*</b> replaced the whole line with a single X. Adding a question mark makes it lazy: <b>.*?</b> gave X and X.

^ and $ match the start and end of the whole text, not each line

The tool's Regex Quick Reference describes them as the start and end of a line, but in our tests they did not behave that way. On - one\n- two\n- three, ^- found 1 match and changed only the first line, and [ \t]+$ found 0 matches in a \nb \nc. Work around it by naming the line break:

Line starts:    (^|\n)- (note the final space)  replace  $1* (final space too)  =>  * one / * two / * three   (3 matches)
Trailing space: [ \t]+(?=\n|$),  replace empty =>  a / b / c                   (2 matches)

The dot does not match a line break

a.b found nothing in a\nb. Use [\s\S] for "any character including a line break": a[\s\S]b matched.

You cannot type a line break in Replace with

Both boxes are single-line fields. A two-line string put into Replace with came back as x y in our test, and typing \n in the replacement inserts a backslash and the letter n, not a line break (a,b,c became a\nb\nc). In Find with regex on, \n and \t do match line breaks and tabs, so you can remove or re-use them. For example, (\n)\s*\n+ replaced with $1 turned a\n\n\n\nb\n\nc into a\nb\nc (all blank lines removed), and (\n\n)\n+ replaced with $1 kept one blank line between paragraphs. If you need to insert new line breaks, use a text editor.

Unicode

The search runs without the Unicode flag. \p{L}+ matched nothing in héllo wörld, and ^.$ did not match a single emoji because an emoji is stored as two units. Case-insensitive search does match ÉCOLE with école, but straße and STRASSE are different words to it.

Empty matches

A pattern that can match nothing, such as x*, matches at every position. On abc it showed 4 matches and the replacement - produced -a-b-c-.

A pattern can freeze the tab

Patterns with a repeated group inside a repeat, like (a+)+$, can take exponentially longer as the text grows. On a string of a characters followed by b, the page took about 0.2 seconds at 20 characters, 1.7 seconds at 24, 3.4 seconds at 26 and 13 seconds at 28 before responding. Because the match count re-runs your pattern as you type, such a pattern can lock the tab before you press anything. Avoid nested repeats, try new patterns on a short sample first, and close the tab if it stops responding.

Speed on ordinary text

For normal patterns it is fast: replacing ipsum with IPSUM in a 1,080,000-character text made 40,000 replacements in about a third of a second on our test machine.

Everyday uses

Privacy

The matching and replacing is done by JavaScript in your browser. We watched the network traffic while pasting text and clicking Replace All: after the page had loaded, no requests were made. The page loads Bootstrap and an icon font from a public CDN when it opens, and the site may show ads from third-party networks that are separate from the tool, so do not paste passwords or other secrets.

Quick answers

Does it replace only the first match? No, it replaces every match.

Is it case sensitive by default? No. Tick Case sensitive to make it so.

Can I undo? Not in the tool. Keep a copy of the original before replacing.

Why did my replacement show $1 literally? That happens when the pattern has no first group, or when Use Regex is off and there are no groups at all.

Which regex flavour is it? The one built into your browser (JavaScript), so look up JavaScript syntax rather than PCRE or Python when you search for help. Lookbehind and named groups worked in our Chromium tests; other browsers may differ for newer features.

Have a repeated edit to make?

Open the Find and Replace Tool