</>CodeKitHub中文

Regex Tester Online

Write a regular expression and see matches highlighted in your test text instantly, as you type. Capture groups are listed per match, and all JavaScript regex flags are supported. Great for building and debugging patterns before putting them in code.

//

    What Is This Tool?

    A regular expression (regex) is a compact pattern language for finding, validating and extracting text: an email pattern can validate form input, \d{4}-\d{2}-\d{2} finds dates, and capture groups pull out the parts you need. Nearly every programming language and editor supports regex.

    This tester uses the JavaScript regex engine — the same one that runs in Node.js and every browser — so patterns you build here behave identically in your JavaScript/TypeScript code. Most patterns also work unchanged in Python, Java and Go.

    Why Use It?

    • Live feedback: matches highlight in yellow as you type the pattern.
    • Capture groups shown per match — see exactly what $1 and $2 will contain.
    • Full flag support: g (all matches), i (ignore case), m (multiline), s (dot matches newline), u (unicode).
    • Clear error messages when the pattern has a syntax mistake.
    • Free and private — pattern and text never leave your browser.

    How to Use

    1. Type your pattern between the two / characters (no need to escape slashes yourself).
    2. Adjust flags in the small box after the second / — the default g finds all matches.
    3. Paste your test text below.
    4. Matches highlight instantly; capture groups are listed underneath.
    5. If the pattern is invalid, the error message explains what's wrong.

    Example

    Input

    Pattern: (\w+)@(\w+)\.com
    Test string: Contact alice@example.com or bob@test.com

    Output

    ✓ 2 matches
    #1 groups: $1=alice  $2=example
    #2 groups: $1=bob  $2=test

    The parentheses create capture groups you can reference as $1 and $2 in replacements.

    Frequently Asked Questions

    Which regex flavor does this tester use?

    JavaScript (ECMAScript), the engine in every browser and Node.js. Core syntax is portable, but some features differ across languages — e.g. lookbehind support and named group syntax vary in Python and Java.

    Why does my pattern only find the first match?

    The g (global) flag is missing. Without g, a regex stops after the first match. This tool defaults to g — check you haven't removed it.

    Why does . not match my line breaks?

    By default . matches any character except newlines. Add the s flag (dotall) to make . match newlines too, or use [\s\S] as a portable alternative.

    What do the capture group results mean?

    Each pair of parentheses in your pattern captures the text it matched. $1 is the first group, $2 the second, and so on — these are what you reference in replace operations and extraction code.

    Why is my regex slow or freezing?

    Likely catastrophic backtracking, caused by nested quantifiers like (a+)+ on non-matching input. Rewrite the pattern to avoid ambiguous repetition. This tool caps at 1000 matches to stay responsive.

    Related Tools