ToolBench

Text

Find and replace

Two modes: literal text for the everyday case, and regular expressions when the thing you are matching has a shape rather than a fixed spelling. The hit count tells you whether the pattern actually matched anything.

How to use it

  1. Paste the text you want to work on.
  2. Type what to find, and what to put in its place.
  3. Tick “Regex” if the search term is a pattern such as \d+ or \s+.
  4. Press Replace — the count of substitutions appears below.

The two mistakes that cost the most time

Greedy quantifiers match more than intended: .* swallows the rest of the line, where .*? stops at the first opportunity. Unescaped dots match any character, so v1.0 also matches v1x0. A pattern that can match an empty string, such as a*, loops forever in a global replace unless the engine advances its position — which is why some replacements appear to hang.

Order matters when chaining replacements

Sequential replacements can undo each other. Replace “cat” with “dog”, then “dog” with “bird”, and every cat has become a bird. When chains are unavoidable, route through a token that cannot occur in the source — cat to __TMP1__, dog to bird, __TMP1__ to dog — or express the whole thing as one alternation so each position is visited once.

Renaming across a project without regret

Run the search first and read every match before replacing anything. A rename of user to account will also hit username, superuser and any string containing the word. Turn on whole-word matching unless you have a reason not to, and check the count before and after — a jump from 40 to 400 matches means the pattern is wrong, not that the work grew.

Replace in one pass rather than chaining, unless the order genuinely matters. Chained replacements can feed their own output back in: replacing A→B and then B→C turns every A into C.

Frequently asked questions

Do I need to escape anything?

In plain mode, no — everything is literal, including dots and brackets. In regex mode, a literal dot must be written as \. and a literal backslash as \\.

Can I use capture groups in the replacement?

Yes. In regex mode $1, $2 and so on refer to the captured groups, so replacing (\w+)@(\w+) with $2 at $1 swaps the halves.

Why did it report zero replacements?

Usually a case mismatch or a regex special character being read literally. Try ticking “Ignore case”, or switch regex mode off.

Is there a limit on replacements?

No limit — every match is replaced. To limit the count, include the constraint in the regex itself.

Can I match across line breaks?

Not in this tool — it works line by line, which keeps the preview predictable. Multi-line patterns need a regex engine with dot-all mode.

Is the replacement literal?

Yes. $1 or \1 are inserted as typed, not expanded, so a literal dollar sign in your text stays intact.