Home/Text tools/Find and replace

Text tool

Find and Replace

Plain text or full regular expressions, with the match count shown before anything is replaced — so a greedy pattern that catches more than you meant shows up before it does damage.

Matches found

2

A compact regex cheat-table

These constructs cover most real find-and-replace jobs. Switch on "treat Find as a regular expression" to use any of them.

The regex building blocks that handle almost everything
PatternMatchesExample
.Any single characterc.t matches cat, cot
*Zero or more of the previous tokenab* matches a, ab, abbb
+One or more of the previous tokenab+ matches ab, abbb, not a
?Zero or one of the previous tokencolou?r matches color and colour
[abc]Any one of the listed characters[aeiou] matches any vowel
\dAny digit, 0–9\d{4} matches a four-digit year
\wLetter, digit or underscore\w+ matches a whole "word" token
\sAny whitespace: space, tab, newline\s+ collapses runs of blank space
^Start of the line^# matches a line beginning with #
$End of the line;$ matches a trailing semicolon
(...)A capture group, reusable in the replacementsee below

Capture groups and $1 replacement

Wrapping part of a pattern in parentheses captures it, and the replacement text can refer back to it with $1, $2 and so on, numbered left to right by opening parenthesis.

Find: (\w+)@(\w+)\.com   Replace: $1 at $2 dot com

jane@example.com becomes jane at example dot com — the two captured groups (the part before @ and the part before .com) are dropped straight into the replacement in order.

Why greedy .* is dangerous

By default, * and + are greedy — they match as much text as possible before backing off. On a multi-line paste, that habit reaches across content you never meant to touch.

Text: <p>First</p><p>Second</p>

Pattern: <p>.*</p>

Greedy match (wrong): the whole string, from the first <p> to the very last </p> — both paragraphs collapse into one match.

Fix: <p>.*?</p> — the added ? makes it lazy, matching as little as possible, so each <p>...</p> pair matches separately instead of the whole block matching once.

This tool matches every occurrence by default (equivalent to the regex g flag), so a greedy pattern's damage shows immediately in the live match count and the result box before you copy anything out.

Questions people ask

What happens if my regex is invalid?

The match count shows an error message describing what the browser's regex engine rejected, and the result box is left unchanged rather than showing broken output. Nothing crashes.

Does plain text mode replace partial words too?

Yes — searching for cat in plain text mode also matches inside category and concatenate. To match whole words only, switch on regex mode and wrap the term in word boundaries: \bcat\b.

Is the search case-sensitive by default?

No, matching is case-insensitive unless you switch the case-sensitive toggle on — both for plain text and regex mode.

Can this handle multi-line patterns, like matching across line breaks?

. does not match a newline by default, matching how most find-and-replace tools behave, so a pattern like <p>.*</p> stays confined to text on the same line unless your pasted content already spans one physical line per match.

Editing text for somewhere else?

Diffing, case conversion and whitespace cleanup sit right next door.

See all text tools →