BOXUNBAOTools
Simplify everyday tasks.Back to website
ToolboxRegex Tester

Regex Tester

Runs in your browser

Test JavaScript regular expressions and inspect matches, capture groups, and replacements.

Matches and capture groups


  

    How to use

    Steps

    1. Enter a JavaScript regex pattern without surrounding slashes. Put flags such as g, i, m in the Flags field.
    2. Paste the content into Test text. To preview a replacement, enter a template under Replace with. You can use $1, $<name> or $&.
    3. Select Test regex. Inspect highlights and positions under Matches and capture groups. Check the replacement preview and select Copy replacement result if needed.

    Example

    Test book-012 card-037 with the pattern below, set flags to g, use a replacement of $<name>_$2, and expect book_012 card_037.

    (?<name>[a-z]+)-(\d{3})

    Tips

    • g matches all occurrences,i ignores case, andm makes anchors match the start and end of each line. An empty replacement deletes the matches.
    • Match offsets are zero-based UTF-16 positions. Test text is limited to 50,000 characters. If there are more than 500 matches or the search times out, narrow the input or simplify the pattern.