Skip to content
ZeroServer.tools

Find and Replace Text

Find and replace text, with live match highlighting, regex and flags.

Matches Found: 0

Plain Text and Regex Replacement

By default the tool replaces every literal occurrence of your search term, and everything you type in “Replace With” is inserted exactly as typed — including a $, so a price like $5.00 or a literal $& survives intact. Toggle regular expression to use full JavaScript regex syntax, where $1 and $& become back-references again — capture groups, named groups and character classes all work.

Whole word matches only at word boundaries, and it understands Unicode: searching мир will not match inside мира, and café will not match inside cafés — which a plain \b boundary gets wrong, because it is defined over ASCII only. The remaining toggles add the i, m, s and u flags; the exact expression in use is shown above the highlighted matches. Every option is captured in the URL, so a copied link reproduces the whole search. All matching and replacement run entirely in your browser.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Renaming an identifier across a pasted block without an editor.
  • Stripping a repeated prefix from every line of a list.
  • Applying a regex substitution to a log extract before analysis.
  • Normalising inconsistent spellings in a block of text.
  • Testing a regex replacement before putting it in a script.

Frequently Asked Questions

What is the difference between plain and regex mode?
Plain mode treats every character literally, so `$1`, `.` and `\n` mean themselves. Regex mode interprets them, which is what you need for patterns — and what silently mangles text when you did not mean it. The mode is the most consequential setting here.
Why does my replacement insert strange text?
Because `$` has special meaning in a replacement string: `$1` is a capture group, `$&` the whole match, and `` $` `` and `$'` are the text before and after it. In plain-text mode those must be escaped, and failing to do so is a real bug this tool has had fixed.
How do I match across lines?
With the `s` flag, so `.` matches a newline, or by using `[\s\S]` which always does. By default `.` stops at a line break, which is why a pattern that works on one line silently matches nothing on a multi-line paste.
What does the global flag change?
Whether every occurrence is replaced or only the first. Without it a replacement stops after one match, which looks like a broken pattern rather than a missing flag — and it is the first thing to check when a replacement half-works.
Can a regex be dangerous?
Yes — nested quantifiers like `(a+)+b` can backtrack exponentially and freeze the tab on a modest input. It is called catastrophic backtracking, and it is a real denial-of-service class in server-side code as well as an annoyance in a browser.

Common errors and gotchas

  • Forgetting to escape regex metacharacters in the search term, so a dot matches everything.
  • Replacing without the global flag and changing only the first occurrence.
  • Matching a substring inside a longer word, where a word boundary was needed.
  • Overlooking case sensitivity, which silently misses half the matches.
  • Using a greedy quantifier that swallows far more than intended between two delimiters.

Related Text Tools tools

Private & free — this tool runs entirely in your browser.