Productivity and Utilities

Regex Tester

Enter a pattern and some text to see every match, its capture groups and what a replacement would produce.

This tester uses the JavaScript RegExp engine. PCRE, Python, Java and other flavors differ in syntax and behavior, so a pattern that works here may need changes elsewhere. Patterns up to 500 characters, text up to 200,000 characters.

Flags

Highlighted matches

Match list

    Patterns run in a separate background worker that is stopped after about 1.5 seconds, so a pattern with catastrophic backtracking cannot freeze this page. Everything runs in your browser and nothing is uploaded. Some browsers also give up on very expensive patterns on their own and report no match, so a pattern that finds nothing in one browser may behave differently in another.

    Next step

    How to use the regex tester

    1. Type your pattern without the surrounding slashes. Turn on the flags you need, such as g to find all matches or i to ignore case.
    2. Paste or type the test text. Matches are highlighted as you type, after a short pause.
    3. Read the match list for each match index and its numbered and named capture groups. Turn on the replacement result, type a replacement such as $2-$1, and check the output.
    4. Copy the matches, or the replacement result, when you are done. If your pattern is invalid or too slow, a message explains what happened.

    Worked example

    The pattern \d+ with the g flag on the text a1b22c333 finds three matches: 1 at index 1, 22 at index 3 and 333 at index 6. Without the g flag only the first match, 1, is found.

    The pattern x* with the g flag on the text ab matches the empty string at index 0, at index 1 and at index 2, so there are three empty matches. The tester steps past each empty match so the search always finishes. Replacing (\d+)-(\d+) with $2-$1 in 12-34 gives 34-12.

    JavaScript flavor only

    This tool uses the JavaScript RegExp engine of your browser, so it matches how a pattern behaves in JavaScript and TypeScript. Other flavors, such as PCRE, Python, Java, .NET and Go, differ in syntax and in features like lookbehind, possessive quantifiers, inline flags and Unicode classes. A pattern that works here may need changes elsewhere, and the reverse is also true.

    Flags

    The flags change how matching works:

    • g finds all matches instead of the first one.
    • i ignores case, and m lets ^ and $ match at line breaks.
    • s lets the dot match a line break, and u turns on Unicode mode.
    • y is sticky, so a match must begin exactly where the last one ended, and d adds the start and end of each capture group.

    Safety limits and the time limit

    Some patterns, such as (a+)+$ on a long run of the letter a followed by an exclamation mark, make the engine try an enormous number of paths. To keep this page responsive, the pattern runs in a separate background worker. If it has not finished after about 1.5 seconds, the worker is stopped and the page tells you that the pattern took too long and may have catastrophic backtracking. Patterns are limited to 500 characters and test text to 200,000 characters, and at most 1,000 matches are shown. Your pattern is only ever used as a regular expression and is never run as code. If the browser cannot start a worker, the tester refuses to run instead of risking a frozen page.

    Related tools

    After matching, you can tidy the text with the case converter, compare lists with compare two lists, or inspect structured data with the JSON viewer. Matched text is shown as plain text and is never inserted as page markup, and everything runs in your browser with nothing uploaded.

    Assumptions and limits

    • Patterns follow JavaScript RegExp syntax in your browser. The exact feature set, such as named groups, lookbehind and the v flag, depends on the browser version.
    • A pattern that runs longer than about 1.5 seconds is stopped, even if it would eventually finish. Rewrite it to avoid nested repeats such as (a+)+.
    • Limits are 500 pattern characters, 200,000 text characters, 2,000 replacement characters and 1,000 listed matches. The replacement result is cut at 1,000,000 characters.
    • Replacement text follows the JavaScript rules: $1 and $<name> insert groups, $& inserts the match and $$ inserts a dollar sign. Without the g flag only the first match is replaced.

    Formulas reviewed October 10, 2026. See the calculation methodology for how SumPanda rounds, tests and sources its formulas.

    Frequently asked questions

    Why does the tester say my pattern took too long?

    The pattern probably has nested or overlapping repeats, such as (a+)+, so the engine tries more combinations as the text grows. The page stops it after about 1.5 seconds. Make the repeat unambiguous, for example use a+ instead of (a+)+, or anchor the pattern more tightly.

    Why do I only see one match?

    Without the g flag a JavaScript regular expression stops after the first match. Turn on the g flag to list every match. The sticky y flag also limits matching to the position where the last match ended.

    What is an empty match?

    A match that has zero length, such as the result of x* where there is no x, or of a boundary like \b. These are shown as a thin marker in the text and as an empty match in the list. The tester always moves one character forward after an empty match, or one whole character under the u flag, so it cannot loop forever.

    How do named groups appear in the results?

    A group written as (?<year>\d{4}) appears twice, once as a numbered group in order and once under its name. Groups that did not take part in the match, for example in an alternation, are marked as such instead of being shown as empty.

    Will my pattern work in Python or PCRE?

    Often, but not always. Basic classes, groups and repeats are similar, but names of groups, lookbehind limits, inline flags and escapes differ. Test the pattern with the flavor you will use, and treat this tool as a check of JavaScript behavior only.