Free Tool · In-Browser · No Upload

Regex Tester

Build and test JavaScript regular expressions with live highlighting, capture groups, and replace and split previews. A built-in guard stops catastrophic patterns before they freeze the tab — and nothing you type leaves your browser.

100% free no signup Zero data uploaded No ads or trackers
Regular expression
/ /
Test string
    Load a pattern:
    Regex cheat sheet

    Character classes

    .
    any char except newline
    \d \D
    digit / non-digit
    \w \W
    word / non-word
    \s \S
    space / non-space
    [abc]
    any of a, b, c
    [^abc]
    none of a, b, c
    [a-z]
    range a to z

    Anchors

    ^
    start of string / line
    $
    end of string / line
    \b \B
    word / non-word boundary

    Quantifiers

    *
    0 or more
    +
    1 or more
    ?
    0 or 1
    {n} {n,} {n,m}
    exact / at-least / range
    *? +?
    lazy (smallest match)

    Groups & alternation

    (…)
    capture group
    (?:…)
    non-capturing group
    (?<name>…)
    named group
    \1
    backreference to group 1
    a|b
    a or b

    Lookaround

    (?=…)
    positive lookahead
    (?!…)
    negative lookahead
    (?<=…)
    positive lookbehind
    (?<!…)
    negative lookbehind
    Recent on this device

    Nothing saved yet. Your recent inputs appear here — stored only in this browser, never uploaded.

    Your data never leaves your browser

    Your pattern and test string are evaluated by your own browser on this page — there's no server, nothing is logged, and matching runs in a sandboxed worker so a runaway pattern can't take the tab down with it.

    How it works

    Three steps, no surprises

    1

    Write your pattern

    Type a regex and toggle flags, or load one from the library. Syntax errors and risky patterns are flagged instantly.

    2

    See it match live

    Matches highlight in your test string as you type, with every capture group listed. Switch to Replace or Split to preview those too.

    3

    Copy, download or share

    Copy the matches or result, download them, or grab a share link that carries your pattern and test data in the URL — never on a server.

    FAQ

    Regex Tester questions, answered

    Why JavaScript regex and not Python/PHP/PCRE?

    The tester runs your pattern with the browser’s own regular-expression engine, which is the JavaScript (ECMAScript) flavour. That keeps it fast and means nothing is sent to a server. Most syntax is shared across flavours, but a few PCRE features — atomic groups, possessive quantifiers, recursion, \K — do not exist in JavaScript. Select the PCRE or POSIX flavour and the tool highlights any constructs that will not run as JavaScript, so you are not caught out.

    What’s “catastrophic backtracking”?

    It is when a pattern can match the same text in exponentially many ways, so the engine tries an explosive number of combinations before giving up. Patterns with nested quantifiers over overlapping characters — classic example (a+)+ against a long string of a’s followed by a non-match — are the usual cause. The tester watches for these shapes, warns you, and aborts any match that runs longer than one second rather than freezing the tab.

    Why does my lookbehind work in your tool but fail on old Safari?

    Lookbehind assertions — (?<=…) and (?<!…) — were added to JavaScript in ES2018. Modern Chrome, Edge and Firefox have supported them for years, and Safari added support in version 16.4 (2023). On older Safari or older WebKit-based browsers the same pattern throws a syntax error. If you need to support those, avoid lookbehind or provide a fallback.

    Can I save my regex for later?

    Yes, in two ways. The Share button encodes your pattern, flags and test string into the URL hash and copies a link you can bookmark or send — the data stays client-side and is never uploaded. The History panel also keeps your recent patterns in your own browser (IndexedDB) so you can reload them on the same device. You can clear history at any time.

    What’s the difference between greedy and lazy quantifiers?

    Greedy quantifiers (* + ? {n,}) match as much as possible, then give back characters only if the rest of the pattern fails. Lazy quantifiers — the same ones followed by ? , such as *? or +? — match as little as possible and expand only as needed. Against <a><b>, the greedy <.*> matches the whole string, while the lazy <.*?> matches just <a>. Reach for lazy quantifiers when you want the smallest match.

    Is my test data sent anywhere?

    No. Your pattern and test string are evaluated by the browser on this page; there is no server involved and nothing is logged. Matching, replacing and splitting all run locally, so your test data never leaves your device.

    Need help with your website's SEO?

    Book a free consultation with our London team.

    Book a Free Consultation