Text & Writing

Find and Replace Text

Replace repeated text with an inspectable preview before you copy the result. Use literal matching for ordinary words or enable JavaScript regular expressions for patterns such as order IDs. A separate worker runs each search and stops difficult patterns after one second.

Free online tool

Loading tool…

All searches run in a worker with a 1-second deadline. Maximum input: 100,000 code units; search: 200; replacement: 10,000; matches: 10,000; output: 500,000. Regex uses Unicode mode. Replacement text is always literal, so $1 and $& are not expanded. Processing stays in this browser; text is not submitted to a server.

Text is processed locally in your browser. No tool input is sent to a remote processing service.

GET STARTED

How to use the Find and Replace Text

  1. 01

    Paste the source text and enter a nonempty search string.

  2. 02

    Enter replacement text, or leave it empty to delete matches.

  3. 03

    Choose literal or regex search, case matching, and whether to replace only the first match.

  4. 04

    Click Preview replacements. Inspect the count, output, and first 100 match offsets before copying or downloading.

Examples

Replace structured IDs

In regex mode, A-\d+ matches A-104 and A-208. Replacing with [order ID] changes both IDs without needing a separate rule for each number.

Delete a literal marker

Search for [draft] in literal mode and leave the replacement empty. Brackets are treated as ordinary characters rather than a regex character class.

Replacement dollar signs stay literal

Replacing cat with $1 yields the text $1, not a capture-group value. This tool intentionally uses literal replacement text in both search modes.

Literal matching is the everyday default

Literal mode escapes regex punctuation, so characters such as periods, parentheses, stars, and brackets match themselves. Matching is non-overlapping: searching for aa in aaa finds one match. Ignore case uses JavaScript’s Unicode-aware regular-expression case behavior rather than a particular language’s spelling rules. The first-only option stops after the earliest match. A nonempty search is required even when the replacement is empty.

Use regex source without slash delimiters

Enter patterns such as ^Order or A-\d+ directly, without surrounding slashes. Unicode mode is always enabled. The multiline option lets ^ and $ anchor to individual lines; it does not make a dot match newline characters. Capture groups can participate in matching, but replacement placeholders such as $1 and $& are not expanded. Each matched span is replaced by the exact text in the replacement field.

Review matches before using the result

The preview shows the entire replacement output and the number of replacements. A table lists the first 100 matches, using zero-based UTF-16 offsets with an exclusive end position. A supplementary-plane emoji occupies two such code units. Empty regex matches are labeled explicitly and advanced by a Unicode code point to prevent an endless match loop. Editing any input clears the previous result, so an old preview is not presented as a result for a new search.

Search limits and cancellation

Every search runs in a module worker with a one-second deadline, including worker startup time. Cancel ends an active run immediately. A complex regex may be valid yet time out; simplify it or use a smaller excerpt. Input allows 100,000 UTF-16 code units, search source 200, and replacement text 10,000. More than 10,000 matches or an output beyond 500,000 code units is rejected instead of being partially exported. Module workers must be supported by the browser.

What to know

  • One-second worker deadline; requires module workers. No capture expansion in replacement text.
  • Maximum 100,000 input code units, 200 pattern code units, 10,000 replacement code units, 10,000 matches, and 500,000 output code units.

Common questions

Does the replacement support $1 or named capture expansion?

No. Replacement text is always literal. Capture groups affect matching, but no replacement interpolation or executable expression is evaluated.

Why did a valid regular expression time out?

Some patterns require excessive backtracking, especially on nearly matching input. The worker is terminated after one second, including startup. Reduce the input or simplify the expression.

Does multiline make a dot match newlines?

No. This option changes only ^ and $ anchors. Use an explicit pattern such as [\s\S] when matching across line breaks is intentional.

Sources & references