Regex tester

Write a regular expression and see every match highlighted as you type, with its capture groups.

Matches highlighted
Match list
    
    
    

    This free online regex tester works in your browser. Everything runs in your browser. What you type is not sent anywhere. All inputs and calculations run locally on your device without server uploads; details on browser processing and storage are set out in the privacy policy.

    Regex flags

    FlagEffect
    gFind all matches, not just the first (always on here)
    iIgnore case
    m^ and $ match at every line
    s. also matches new lines
    uFull Unicode, needed for \p{L} letter classes
    ySticky: match only at lastIndex

    Cheat sheet

    PatternMatches
    \d \w \sDigit, word character, white space
    [abc] [^abc]One of / none of these characters
    a* a+ a?Zero or more, one or more, optional
    a{2,4}Between 2 and 4 times
    ^ $Start and end of text (or line, with m)
    \bA word boundary
    (…) (?:…)Capture group, non-capturing group
    (?<name>…)Named group
    (?=…) (?!…)Followed by / not followed by
    (?<=…) (?<!…)Preceded by / not preceded by

    This tester uses your browser’s JavaScript regex engine. Python, PHP (PCRE) and Java behave the same for most patterns, but differ in some advanced features.

    Worked example: Extracting semantic version numbers (`v2.14.0-beta.1`) with named capture groups

    Suppose you want to match release tags and separate the major, minor, patch, and optional pre-release label using JavaScript's RegExp engine:

    • Pattern: \bv(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?:-(?<prerelease>[0-9A-Za-z.-]+))?\b
    • Flags: g (global, to find all matches in the text).
    • Test string: Upgraded from v1.9.4 to v2.14.0-beta.1 on node-03.
    • Matches and capture groups returned:
      • Match 1 (index 14–20): v1.9.4 → major: "1", minor: "9", patch: "4", prerelease: undefined.
      • Match 2 (index 24–38): v2.14.0-beta.1 → major: "2", minor: "14", patch: "0", prerelease: "beta.1".

    Limits and what this tool cannot do

    • Uses your browser's JavaScript (ECMAScript) RegExp engine: While ECMAScript 2018+ supports lookbehind assertions ((?<=...) and (?<!...)), named capture groups ((?<name>...)), and Unicode property escapes (\p{Script=Devanagari} with the u flag), it does not support PCRE/Python-only features such as recursive patterns ((?R)), atomic groups ((?>...)), or possessive quantifiers (++, *+).
    • Catastrophic backtracking (ReDoS) on nested quantifiers: Patterns with nested repeating groups like (a+)+b tested against a long string of aaaa...c cause exponential backtracking in NFA regex engines and can freeze the tab.

    Questions

    Why does my pattern match nothing?

    Check for unescaped special characters: . * + ? ( ) [ ] { } | \ ^ $ have meanings. To match a literal dot, write \..

    Does it save my patterns?

    No. Nothing leaves your browser.

    Can a regex freeze the page?

    Patterns with nested repeats, like (a+)+, can take extremely long on some inputs. If the page stops responding, reload it and simplify the pattern.

    What is the difference between a capturing group (...) and a non-capturing group (?:...)?

    Parentheses (...) both group tokens together and save the matched substring into the numbered capture array ($1, $2). Writing (?:...) groups tokens so you can apply ?, +, or | to them without cluttering your capture group output.

    Why didn't ^ and $ match the start and end of each line in my multi-line text?

    By default, ^ and $ match only the very beginning and very end of the entire string. Tick the m (multiline) flag so ^ and $ match the start and end of every individual line (\n).

    How do I match any character including newlines?

    Normally a dot (.) matches everything except a newline (\n). Tick the s (dotAll) flag—or write [\s\S]—so . matches across line breaks too.

    Last reviewed .

    Related converters and guides