YourTools.
简体中文
Back to the catalog
Tools

Regex find and replace

Replace or extract text with a JavaScript regular expression. Runs in an isolated worker with a hard time limit.

Process locally

Files stay in this browser session. Closing or clearing releases them.

Add text

Type or paste the text to process

Adjust settings

Optional: Pattern, Mode, Replacement and more

Regex find and replace

Run

Processes in this browser; cancel at any time

Add text first

About this tool

Find and replace text with a regular expression, or pull out every match. Use it to collapse extra spaces, reformat dates, mask phone numbers, or collect all email addresses or order numbers from a log.

Patterns use JavaScript syntax with optional ignore-case, multiline and dot-all flags, and replacements can insert capture groups with $1. Matching runs in a separate worker that is stopped after 10 seconds, so a runaway pattern cannot freeze the page, and more than 10,000 matches end the run with an error. Your text stays in the browser and is not uploaded.

How to use it

  1. Paste your text, or select Use example.
  2. Enter the “Pattern” without surrounding slashes, and choose a “Mode”: “Replace every match” or “Extract matches”.
  3. When replacing, fill in “Replacement”. Tick “Ignore case”, “^ and $ match each line” or “. matches line breaks” if needed.
  4. Select Run, then preview and download the text result (replaced.txt or matches.txt) and matches.json.

Formats and limits

Input
Text
Output
Plain text, JSON
Size limit
1 MB
Settings
Pattern; Mode (Replace every match, Extract matches); Replacement; Ignore case; ^ and $ match each line; . matches line breaks
Privacy
Files stay in the current browser session. No file bytes are uploaded.
Price
Free, no sign-up

Common questions

Which regex syntax and flags are supported?

The pattern is a JavaScript regular expression typed without slashes or flags; the g flag is always on, and the three checkboxes add i, m and s. The u flag is not set, so \p{…} property escapes do not work; use a range such as [\u4e00-\u9fa5] to match common Chinese characters.

How do I use capture groups in the replacement?

Write $1, $2 and so on for numbered groups, $<name> for a named group (?<name>…), and $& for the whole match; type $$ for a literal dollar sign. For example, the pattern (\d{4})-(\d{2})-(\d{2}) with the replacement $3/$2/$1 turns 2026-10-17 into 17/10/2026.

Can I replace matches with a line break?

Not here. “Replacement” is a single-line field, and escapes such as \n are inserted as the two characters \ and n.

In extract mode, how do I get only the capture groups?

The text result, matches.txt, lists each whole match on its own line. The groups of every match, including named groups, are in matches.json together with the position of each match.

Why does my run stop with an error?

A syntax error in the pattern is reported before any matching starts. A run also stops if it takes longer than 10 seconds, which usually means catastrophic backtracking from nested quantifiers such as (a+)+, or if there are more than 10,000 matches, in either mode.

Workflows that use this tool