Skip to content
Language:en

Regex tester

Test a regular expression live: highlighted matches, capture groups and replacement.

Flags

Matches

Match details

    Replace

    $1, $<name>, $& and $$ are supported.

    Runs entirely in your browser. Your files never leave your device.

    About this tool

    Writing a regular expression is trial and error. Type a pattern and some sample text, and every match is highlighted as you type, with its position and the content of each capture group, numbered or named. Toggle the global, case-insensitive, multiline, dot-all and Unicode flags to see how they change the result.

    The replacement panel previews a search and replace on the whole text, with $1, $ and $& references, which is the safest way to test a bulk edit before running it in your editor or code. The pattern and flags are kept in the link so you can share a regex with a colleague; your test text stays on your device.

    How it works

    1. Type the pattern without the surrounding slashes.
    2. Choose the flags.
    3. Paste the text to test and read the highlighted matches and groups.
    4. Optionally type a replacement and copy the result.

    The tool uses your browser’s JavaScript engine (ECMAScript syntax): lookbehind, named groups and Unicode property escapes are supported. Other flavours such as PCRE or Python differ on a few points.

    Worked example

    To turn ISO dates into day/month/year, use the pattern (\d{4})-(\d{2})-(\d{2}) with the g flag: on “Due 2026-11-29, paid 2026-12-03” both dates are highlighted with their three groups. The replacement $3/$2/$1 previews “Due 29/11/2026, paid 03/12/2026”.

    Share the link with a colleague: it keeps the pattern and flags, not your test text.

    Good to know

    • Without the g flag, only the first match is found; that is the most common surprise.
    • Anchor patterns with ^ and $ (and the m flag for multiline text) when validating whole lines.
    • Nested quantifiers such as (a+)+ can freeze any regex engine on long text; simplify them.

    Frequently asked questions

    Why do I only get one match?
    Without the g (global) flag a regex stops at the first match. Turn g on to find them all.
    How do I reference a group in the replacement?
    Use $1, $2… for numbered groups, $ for named groups, $& for the whole match and $$ for a literal dollar sign.
    Will a regex written here work in Python or PHP?
    Simple patterns usually do. Watch for differences: Python names groups (?P…), and some features such as possessive quantifiers exist in PCRE but not in JavaScript.
    The page froze with my pattern, why?
    Nested quantifiers such as (a+)+ can cause catastrophic backtracking on some inputs. Simplify the pattern or make the quantifiers more specific.