Skip to content

Find and Replace

Bulk edits, with regex when you need it.

  • Nothing is sent to a server
  • Instant results
  • Free, no sign-up
All text tools

Questions

Are special characters treated literally?

Yes, unless you switch on regular expressions. Searching for 'a.b' finds 'a.b' and not 'axb', and searching for '1+1' works exactly as you would expect. That is the right default, because most replacements are literal and an accidental metacharacter is a confusing way to get the wrong answer.

What does 'whole word only' protect against?

The classic mass-replace disaster. Replacing 'cat' with 'dog' across a document without it also turns 'concatenate' into 'condogenate'. Whole-word matching wraps the search in word boundaries so only standalone occurrences match. It is the option worth reaching for before you replace anything across a long document.

How do capture groups work?

In regex mode, $1 to $9 insert the corresponding capture group, $& inserts the whole match, and $$ inserts a literal dollar sign. So searching (\w+) (\w+) and replacing with '$2, $1' turns 'John Smith' into 'Smith, John' across a whole list of names in a single pass.

Why was my pattern rejected?

Either it is not valid — in which case the engine's own error message is shown — or it can match the empty string. Patterns like x*, \d? or (a|) match nothing at every position, so a global replace inserts the replacement between every character. That is never intended and looks like a bug in the tool rather than in the pattern, so it is refused up front.

Is there a size limit?

No. The replacement runs in your browser, and recalculation is deferred behind your keystrokes so typing stays responsive on long documents. Nothing is uploaded, logged or stored, which makes it safe for confidential drafts, client work and anything under NDA.

About find and replace

Literal by default

With regular expressions switched off, everything you type is matched literally — including characters that would otherwise be special. Searching for a.b finds a.b and not axb, and searching for 1+1 works exactly as you would expect. That is the right default, because most replacements are literal and an accidental metacharacter is a confusing way to get the wrong answer.

What the three options do

  • Match case — off by default, so Cat and cat are the same. Turn it on for code, identifiers and anything case-significant.
  • Whole word only — wraps the search in word boundaries, so cat matches cat but not concatenate. This is the option that prevents the classic mass-replace disaster.
  • Regular expression — treats the search as a pattern and enables capture groups in the replacement.

Capture groups

In regex mode the replacement understands the standard tokens:

TokenInserts
$1$9The corresponding capture group
$&The whole match
$$A literal dollar sign

So searching (\w+) (\w+) and replacing with $2, $1turns “John Smith” into “Smith, John” across a whole list of names in one pass.

Patterns worth knowing

GoalPattern
Collapse multiple spaces + → single space
Strip trailing whitespace[ \t]+$ → nothing
Remove blank lines\n\s*\n\n
Keep digits only[^0-9] → nothing
Swap date order(\d+)/(\d+)/(\d+)$3-$2-$1

One pattern the tool refuses

Anything that can match the empty string — x*, \d?, (a|)— is rejected rather than run. A global replace on an empty-matching pattern inserts the replacement between every character, which is never what anyone wants and looks like a bug in the tool rather than in the pattern. An invalid pattern is reported with the engine’s own message instead of failing silently.

Related

Browse the rest of the text tools, or check what changed with the diff checker.