Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Regex tester

Test a regular expression on your own text: see every match and group, preview replacements, and read what each part of the pattern means.

Flags

Matches: –


  
#PositionMatchGroups

Replace and split

What the pattern means

    As JavaScript:

    Turn plain text into a pattern

    How to use

    1. Type a pattern between the slashes, or pick a common pattern to start from.
    2. Tick the flags you need. Without g only the first match is found.
    3. Type or paste your test text. Matches are marked as you type, and the table lists each match with its groups.
    4. Tick Replace with to preview a replacement: $1 is group 1, $<name> a named group, $& the whole match.
    5. Read What the pattern means to check each part does what you expect.

    Keyboard and touch

    TabMove between the pattern, flags, text and replacement
    SpaceTick or untick a flag
    EnterRun the pattern again (in the pattern box)

    Tips

    • Escape special characters with a backslash: \. is a real full stop, . is any character.
    • .* is greedy and grabs as much as it can; .*? takes as little as possible.
    • Use (?:…) when you only need grouping, and (?<name>…) to give a group a readable name.
    • Nested repeats such as (a+)+ can take forever on text that almost matches. The tester stops after 2 seconds and tells you.
    • A simple email or phone pattern is a quick check, not a guarantee that the address or number exists.

    About this tester

    Patterns run in your browser's own JavaScript regular expression engine, so the results are exactly what JavaScript code would get. Other languages (Python, PCRE, Java) agree on most basics but differ in some details, such as look-behind and named groups.

    Matching runs in a background worker, so a slow pattern cannot freeze the page. Up to 1,000 matches are found and the first 200 are listed. The explanation is our own token-by-token reading of the pattern.

    Nothing is stored or sent: your pattern and text stay on your device.

    See you tomorrow!

    A fresh daily puzzle every morning, and new tools added every month.

    Browse every product