Text Tools

Regex Replace

Replace text using JavaScript regular expressions, capture groups and optional flags. Preview the result in a cancellable local worker, then copy or download it privately.

Your content stays on your device Free, with no account
A pattern for the changes you need Local worker · 3-second limit
Up to 100,000 UTF-16 text units.
Pattern only, without / delimiters. Up to 2,000 text units.
Up to 20,000 text units. Capture references are supported; backslash escapes are not expanded here.
YOUR RESULT

Ready. Enter a JavaScript pattern and replacement.

Turn off Match all to replace only the first match. Text and markup are never executed. Edits cancel pending work and clear the old result.

Replacement quick reference

$1–$99: numbered capture · $<name>: named capture · $&: whole match · $$: literal dollar · $`: original text before the match · $': original text after the match.

Use actual line breaks in the replacement field; \n stays literal there. Output is limited to 1,000,000 text units and 20,000 processed matches. Complex patterns may be stopped with no partial result.

JavaScript replacement syntax ↗
A FEW SIMPLE STEPS

How to use Regex Replace

  1. Paste original text and enter a JavaScript regular expression without surrounding slashes.
  2. Enter replacement text, using capture references such as $1 or $<name> if needed. Choose matching flags.
  3. Select Replace with regex. Work runs locally in a disposable worker; Cancel or edit a field to stop it.
  4. Review processed match count and the result, then copy or download TXT. Failed or timed-out runs do not expose partial results.
PRIVATE BY DESIGN

Why use this tool?

Your pattern and text are processed on your device with no uploads, account, dependencies or browser storage. A disposable worker keeps slow expressions away from the page, with cancellation and a time limit. The original remains available and outputs are always plain text.

Tool inputs stay in your browser. Only your theme preference is saved on this device.

A few things worth knowing

Which regex dialect and flags are supported?

The tool uses your browser’s JavaScript RegExp engine. Enter the pattern without / delimiters. Supported flags are g for all matches, i for case-insensitive matching, m for line anchors, s for dot matching newlines and u for Unicode mode. Other dialects and flags are not supported. Advanced syntax depends on your browser.

How do replacement capture groups work?

Use $1–$99 for numbered captures, $<name> for named captures, $& for the whole match and $$ for a literal dollar sign. The original prefix and suffix are available through dollar-backtick and dollar-apostrophe. Unmatched optional captures insert empty text. Unknown references follow JavaScript string-replacement rules.

Can I use backslash escapes or a replacement function?

Backslash-n stays literal in the replacement field; insert an actual line break when needed. Pattern escapes such as backslash-n and backslash-d have their normal regex meaning. JavaScript replacement functions and executable replacement code are not supported.

What happens with zero-width matches or first-only mode?

Global zero-width matches advance after each match so processing cannot loop forever on the same position. Unicode mode advances over a complete Unicode code point. Turning off Match all processes only the first match, so the displayed count is not a count of all possible matches. To match empty positions explicitly, enter (?:); an empty pattern field is rejected.

Why did the expression stop?

Processing is stopped after about three seconds, including worker startup, or when you cancel, edit the input or leave the page. The limits are 100,000 input UTF-16 units, 2,000 pattern units, 20,000 replacement units, 20,000 processed matches and 1,000,000 output units. Exceeding a limit gives no partial result. Simplify the expression or compare a smaller passage.

Is the input changed or uploaded?

No. Your original text stays in the editor and is not uploaded or saved in browser storage. CRLF and CR line endings normalize to LF. Markup is displayed as plain text. Clear empties text fields but keeps flag choices; Try an example loads a working capture-group example and its flags.