Regex Tester & Replacer

Test JavaScript regular expressions against any string with live match highlighting, capture groups (named and numbered), and optional replace.

Runs 100% in your browser — nothing is uploaded.Use this in a chain
//gm
Matches3
Contact ada@example.com or grace@nasa.gov to volunteer.
Alan.turing@bletchley.uk maintains the crypto machines.
Match details
  • #1 @ 8: ada@example.com
    Groups: $1=ada$2=example.com
  • #2 @ 27: grace@nasa.gov
    Groups: $1=grace$2=nasa.gov
  • #3 @ 61: turing@bletchley.uk
    Groups: $1=turing$2=bletchley.uk

How to use

  1. 1
    Write your pattern

    JavaScript regex syntax. No leading /…/ delimiters — just the pattern.

  2. 2
    Pick flags

    i = case-insensitive · m = multiline · s = dotAll · u = unicode. The g (global) flag is always on so all matches show.

  3. 3
    Paste text to test against

    Every match highlights live, with named and numbered capture groups shown below.

  4. 4
    Try a replacement

    Optional replacement box supports $1 $2 backrefs and $<name> for named groups.

Examples

Extract email addresses
Input
Pattern: [\w.+-]+@[\w-]+\.[\w.-]+
Text: contact alex@example.com or team@toolvaults.net
Output
Matches: alex@example.com · team@toolvaults.net
A pragmatic email pattern. The truly RFC-compliant one is a lot uglier.
Named capture groups
Input
Pattern: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
Text: 2026-08-14
Output
Match: 2026-08-14
Groups: year=2026, month=08, day=14
Groups appear labeled below the match list.
Replace with backreferences
Input
Pattern: (\w+)\s(\w+)
Text: Hello World
Replace: $2 $1
Output
World Hello
Swap two words using positional backreferences.

Frequently asked

Which regex flavor is this?

JavaScript / ECMAScript regex (via the browser's native RegExp). Very close to Perl-compatible (PCRE) but with a few differences around lookbehinds, unicode, and named groups.

Why is the "g" flag always on?

Without global mode you'd only ever see one match. The tool forces "g" so all matches are shown; other flags are yours to toggle.

What does "sticky" do?

The "y" flag forces the match to start exactly at lastIndex. Rarely useful interactively — mainly for building high-performance tokenizers.

Related tools