Zero Signup ToolsFree browser tools

Developer Tools

Regex Replace Tester

Test regex replacement patterns with capture groups in your browser. Live result, per-match breakdown, and code snippets for JavaScript, Python, and sed.

Flags

JavaScript replacement syntax. Use $1, $2 for numbered groups, $<name> for named groups, $& for the whole match.

Quick samples

35 chars

Match breakdown

  • Match 1index 9end 19length 10

    Matched

    2026-05-07

    Replaced with

    05/07/2026

    Capture groups

    • $<y>2026
    • $<m>05
    • $<d>07
  • Match 2index 24end 34length 10

    Matched

    2024-12-31

    Replaced with

    12/31/2024

    Capture groups

    • $<y>2024
    • $<m>12
    • $<d>31

Replacement template reference

  • $&The entire matched substring.
  • $`The portion of the input before the match.
  • $'The portion of the input after the match.
  • $$A literal dollar sign.
  • $1, $2, ...Numbered capture groups, starting at 1.
  • $<name>A named capture group, written (?<name>...).

Use this in code

JavaScript
const result = input.replace(/(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})/g, "$<m>/$<d>/$<y>");
Python
import re
result = re.sub(r"(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})", "\\g<m>/\\g<d>/\\g<y>", input)
sed
sed -E 's/(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})/\<m>\/\<d>\/\<y>/g'

sed uses POSIX ERE and does not support named groups or lookarounds. Numbered backreferences are translated to backslash-N form.

How to use

  1. Type or paste a regular expression into the pattern field.
  2. Toggle the g, i, m, s, u, and y flags to match the behavior you want.
  3. Type a replacement template. Use $1, $2 for numbered captures, $<name> for named captures, and $& for the whole match.
  4. Paste the sample text you want to run the replacement on into the test area.
  5. Read the live result, the match count, and the per-match breakdown to confirm each substitution is what you expect.
  6. Open the Use-this-in-code panel and copy the JavaScript, Python, or sed snippet to paste straight into your codebase.

About this tool

Regex Replace Tester is a focused sandbox for testing regular expression substitution patterns before pasting them into code. Type a pattern, pick the g, i, m, s, u, and y flags, type a replacement template, and paste any sample text. The tool compiles your pattern with the same JavaScript RegExp engine your code will run, applies the replacement, and shows the final output, the count of replaced matches, and a per-match breakdown that lists each match, every numbered and named capture group, and the exact replacement string that match produced. Replacement template syntax follows the JavaScript String.prototype.replace rules and is fully documented on the page: $& for the whole match, $` for the text before the match, $' for the text after the match, $$ for a literal dollar sign, $1 through $99 for numbered capture groups, and $<name> for named capture groups declared as (?<name>...). The result panel honors your flag choice, so removing the g flag replaces only the first match the way the engine does at runtime. Quick samples cover the substitutions developers reach for most often: rewriting ISO dates to US format, obfuscating email addresses, formatting US phone numbers, swapping first and last names, wrapping matches in HTML tags, and stripping tags from a snippet. The Use-this-in-code panel exports your tested pattern and replacement as a ready-to-paste JavaScript replace call, a Python re.sub call (with JavaScript replacement tokens translated into Python backreference syntax), and a sed -E command (with numbered backreferences translated and unsupported features flagged) so the tested expression goes straight into source code or a shell pipeline. Pattern errors surface inline as you type, and runaway empty-match loops, oversized inputs, and runaway match counts are bounded so the page stays responsive. Everything runs locally in the browser: the pattern, replacement, and test text never leave your device, which makes the tool safe for debugging substitutions against confidential logs, customer data, or production strings.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools