Regex Replace Tester

Test regex search and replace in real time with match highlights and capture group details.

Input data is processed in your browser
Data is never sent to a server

Tool

Use $1, $2 … to reference capture groups

or drag & drop a file

Quick Reference

Patterns

.any character except newline\ddigit [0-9]\wword character [a-zA-Z0-9_]\swhitespace^start of string / line$end of string / line*0 or more+1 or more?0 or 1 (optional){n,m}between n and m times(abc)capture group(?:abc)non-capturing group(?<name>)named capture group[abc]character classa|balternation (a or b)

Replacement tokens

$&entire match$1 $2capture group 1, 2, …$<name>named capture group$'string after match$`string before match$$literal $

What is Regex Replace Tester?

Regex Replace Tester lets you interactively build and test regular expression search-and-replace operations in real time.

It highlights matches in the source text, shows each match’s index, length, and capture groups in detail, and displays the final replaced string — all at once as you type. The built-in quick reference for patterns and replacement tokens makes it useful for both debugging and learning regex.

How to Use

  1. Enter a regex pattern in the pattern field (no slashes needed).
  2. Toggle flags (g, i, m, s) with the flag buttons.
  3. Enter a replacement string — use $1, $2 to reference capture groups.
  4. Type or paste your test string to see highlights and the replacement result instantly.

FAQ

Which flags are supported?

g (global — find all matches), i (case-insensitive), m (multiline — ^ and $ match line boundaries), and s (dotAll — . matches newlines).

How do I reference capture groups in the replacement?

Use $1, $2, … for numbered groups, $<name> for named groups. $& inserts the entire match, $` inserts the text before the match, and $' inserts the text after the match.

Are zero-width matches handled correctly?

Yes. Zero-width matches like ^ and lookaheads are handled safely to prevent infinite loops during global replacement.

Is my data sent to a server?

No. All processing uses the JavaScript regex engine running entirely in your browser.