Regex Explainer

Regex Explainer

Regex explainer online. Break down regex patterns into tokens with plain English explanations. Understand any regex visually—free regex breakdown tool.

📖

Pattern to Explain

Enter any regex to understand what it does

/ /

🎨 Token Types Legend

📝
literal
anchor
🔢
quantifier
📦
class
🔗
group
🔐
escape
🔀
alternation
👀
lookaround

Features

  • Token-by-token visual breakdown of any regex pattern
  • Color-coded token types: anchors, quantifiers, groups, character classes, escapes, lookarounds
  • Interactive hover & click to inspect individual tokens
  • Complexity score to gauge pattern difficulty
  • Natural-language plain English summary of the pattern
  • Complete token list with type, character range, and explanation
  • Quick patterns for common use cases (Email, URL, Phone, etc.)
  • "Try in Tester" shortcut to test the explained pattern live

Common Use Cases

  • Understand a complicated regex found in legacy code
  • Learn regex syntax through interactive exploration
  • Debug a broken pattern by examining each component
  • Review a regex submitted in a pull request
  • Explain a pattern to a less experienced team member

How Regex Parsing Works

A regex engine reads a pattern character by character, converting it into an internal state machine. Each token is a unit of meaning: a literal character, a metacharacter (like . or *), an escape sequence, or a group boundary.

Understanding tokens is the key to mastering regex. When you know what each piece does in isolation, you can build and diagnose complex patterns with confidence.

Token types include: Anchors (^, $, \b), Quantifiers (*, +, ?, {n,m}), Character Classes ([abc], \d, \w), Groups ((...), (?:...)), and Lookarounds ((?=...), (?!...)).

Examples

Valid - Email
^[\w.+-]+@[\w.-]+\.[a-zA-Z]{2,}$
Valid - URL
https?:\/\/[\w.-]+(?:\.[\w.-]+)+[\w\-.~:/?#@!$&'()*+,;=%]*
Valid - Named Group
(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
Valid - Lookahead
\d+(?= dollars)

Frequently Asked Questions

What is a capturing group vs non-capturing group?

A capturing group (...) matches a sub-expression and saves the matched text for later use (back-references or extraction). A non-capturing group (?:...) groups without saving the match — useful for applying a quantifier to multiple characters without the overhead of capturing.

What is a lookahead and why is it useful?

A positive lookahead (?=...) asserts that what follows the current position matches the given pattern, without consuming characters. For example, \d+(?= dollars) matches a number only if followed by " dollars". A negative lookahead (?!...) asserts the opposite.

What does the complexity score mean?

The complexity score is a heuristic that weights each token type: lookarounds and groups are high-value (harder to reason about), while literals are low-value. A "Very Complex" score above 50 suggests the pattern may be difficult to maintain and worth simplifying or documenting thoroughly.

What is a word boundary (\b)?

\b is a zero-width assertion that matches the position between a word character (\w) and a non-word character (or the start/end of the string). \bcat\b matches "cat" in "a cat sat" but not in "catch".

How do I match a specific number of repetitions?

Use a quantifier range: {n} for exactly n times, {n,} for n or more, and {n,m} for between n and m times. For example, \d{4} matches exactly 4 digits.

💡 Tips

  • Click a token in the breakdown to "pin" its explanation even as you move your mouse.
  • Paste a regex from your codebase directly into the input — even complex production patterns can be decoded.
  • Use the complexity score as a signal: if it's "Very Complex", consider splitting the regex into two simpler ones.
  • Named capture groups (<code>(?&lt;name&gt;...)</code>) make complex patterns much more readable and maintainable.
  • The natural-language summary is approximate — always verify the token breakdown for accuracy in edge cases.