Back to AllToolio

Regex Tester

Check regular expression matches and preview replacements.

0
Matches
0
Groups

    How to use the regex tester

    1. Type your regular expression into the pattern field and add flags if needed.
    2. Paste the text you want to search in the test area.
    3. Press Test to list every match and count the capture groups, or type a replacement and press Replace.
    4. Review the result in the output and replacement areas.
    5. Start with a small pattern and grow it step by step, checking the matches after each change.

    When it helps

    • Debugging a regular expression before using it in code.
    • Finding and replacing patterns across a block of text.
    • Extracting values such as emails or dates from a document.
    • Checking how capture groups behave.
    • Extracting version numbers from a log file.

    How matches and replacements are counted

    For the match list, RegExp.exec runs on a copy with g enabled. Replacement uses String.replace with precisely the flags you entered, so omitting g can leave later matches unchanged. The groups card counts capturing groups per match, not the total number of captured values. Empty matches advance the search position by one.

    Example: rearranging two reference codes

    Set the pattern to ([A-Z]+)-(\d+), keep flag g, and enter AB-12 CD-34 as the test text. Use $2:$1 as the replacement. The list contains AB-12 and CD-34; the cards show 2 matches and 2 groups. The replacement result is “12:AB 34:CD”, because each replacement places the second captured group before the first.

    Frequently asked questions

    Is my pattern and text private?

    Yes. Everything is evaluated locally in your browser and never sent to a server.

    What are the limitations?

    The tester uses the JavaScript regular expression engine of your browser, so features from other engines may behave differently. Invalid patterns are reported rather than matched.

    Which flags are supported?

    You can add the common JavaScript flags such as case-insensitive, global, and multiline in the flags field.

    Can I test replacements?

    Yes. The replacement field shows how the text changes after the pattern is substituted.

    Does it show capture groups?

    It shows how many capture groups the pattern has, and the list contains each whole match. To see what a group captured, use $1, $2 and so on in the replacement and check the replaced text.

    Why does my pattern find no matches?

    The most common reasons are a typo in the pattern, a missing flag, or a pattern that expects characters that are not in the text. Start with a simpler fragment and confirm it matches before adding groups or anchors. The result area shows zero matches when nothing matches, so you can iterate quickly.

    Related tools

    Text and developer tools

    This season