Regex Tester & Explainer

Type a regular expression and a test string to see matches highlighted in real time. Below the matches, every token in your pattern is explained in plain English so you actually understand what you wrote. Nothing uploaded.

Live match highlights Token explanation tree Capture groups ? Replace mode g · i · m · s flags ?
-
Test string
Matches

Pattern explanation

    Match table

    Learn more: Regular expressions and pattern matching

    The problem with regex tools

    Most regex testers tell you whether your pattern matches and which substrings it captures, but not why. regex101.com is accurate but terse - it assumes familiarity with terms like "possessive quantifier" and "atomic group". For developers who write regex occasionally, understanding what you've written is crucial for future maintenance.

    Match highlighting plus token-by-token explanation

    Type your pattern and matches highlight in real-time. Every token gets a plain-English description: "any digit 0-9", "word boundary", "one or more times (greedy)". The match table shows every occurrence with its start position and capture groups. You can also switch to Replace mode to test substitutions.

    FAQ

    What does the global (g) flag do in regular expressions?

    The global flag tells the regex engine to find all matches in the string, not just the first one. Without g, .exec() and .match() only return the first match. With g, you get an array of all matches. This is essential for find-and-replace operations or counting occurrences.

    What is a capture group in a regular expression?

    A capture group, written as (...), saves the text matched inside the parentheses so you can refer to it later. In a replacement string, $1 refers to the first capture group, $2 to the second. For example, the pattern (\\w+)@(\\w+) on 'user@email' captures 'user' as $1 and 'email' as $2.

    How do I match email addresses with a regular expression?

    A practical email regex for basic validation is: ^[\\w.-]+@[\\w-]+\\.[a-zA-Z]{2,}$. This matches most common email formats. Note that fully RFC-5321 compliant email validation requires a much more complex pattern - for production use, validate by sending a confirmation email rather than relying on regex alone.

    Last reviewed: May 31, 2026