Find & Replace (Regex)

Find and replace across text with plain search or a regular expression, with capture groups, a live match count and protection against patterns that hang.

Matching and replacement both run in a worker thread in your browser. Nothing you paste is uploaded, and a pattern that hangs is terminated rather than freezing the page.

What It Does

Search and replace across a body of text, either literally or with a regular expression. The literal mode escapes your search term for you, which matters more than it sounds — a search for a price like $9.99 read as a pattern means something entirely different and matches almost nothing you intended. In regex mode you get capture groups in the replacement, referenced as $1 or by name, plus the flags that actually change behaviour: global, case-insensitive, multiline and dotall. The match count updates as you type, so you can see whether a pattern is doing what you think before you commit to the replacement. Everything runs in a worker thread, which means a catastrophically slow pattern gets terminated and reported rather than freezing the page — and being told your pattern is a ReDoS risk is more useful than any match list.

When to Use It

  • A configuration file needs the same value changed in forty places and your editor's replace is not available.
  • An export has inconsistent formatting and you need to normalise it before importing.
  • You are reformatting a list of values and want to reorder each line using capture groups.
  • A log file needs sensitive values redacted before you can share it.
  • You want to check what a pattern would actually match before running it against real data.

Worked Examples

Capture groups in practice. A pattern of (\w+)@([\w.]+) with a replacement of $2 / $1 flips each line to show the domain first — the sort of restructuring a literal replacement cannot do.

Item 1: $9.99 Item 2: $19.50

The literal-versus-pattern case. Searching for $9.99 as a regex means end-of-string then any character then 99, which matches nothing here. Plain text mode escapes it and finds it immediately.

spaced out text

A pattern of \s+ with a single space as the replacement collapses every run of whitespace at once. The global flag is what makes it apply throughout rather than only to the first run.

Features

Plain text or regular expression search
Capture groups referenced by number or name
Global
case-insensitive
multiline and dotall flags
Live match count as you type
Preview of the first matches with their positions
Replacement runs in a worker so a slow pattern cannot freeze the page
Catastrophic backtracking detected and reported as a ReDoS risk
Replacement count reported after applying
Search term escaped automatically in plain text mode
Runs entirely in your browser

How to Use

1. Paste the text you want to work on. 2. Enter what to find, choosing plain text or regex. 3. Watch the match count to confirm the pattern does what you expect. 4. Enter the replacement, using $1 or $<name> for capture groups. 5. Copy the result once the count looks right.

Common Mistakes

  • Forgetting the global flag. Without it only the first match is replaced, and nothing in the output tells you the rest were skipped.
  • Treating a search term as literal when it is being read as a pattern. Dollar signs, dots, brackets and question marks all mean something to a regex — use plain text mode or escape them.
  • Writing nested quantifiers like (a+)+. Against input that nearly matches these take exponential time, which is a hang here and a denial-of-service risk on a server.
  • Expecting caret and dollar to work per line by default. They match the whole input's start and end unless the multiline flag is on.
  • Running a replacement on real data before checking the match count. Seeing how many times a pattern matches is the cheapest way to catch a mistake before it is applied.

Frequently Asked Questions

Related Tools