Regex Explainer

Parse and explain regular expressions in plain English

Enter regex without delimiters

Token Types

LiteralMetacharQuantifierGroupAnchorChar ClassEscapeSpecial

What is Regex Explainer?

Regular expressions (regex) are patterns used to match text. They combine literal characters, metacharacters, quantifiers, and special constructs to create powerful text matching rules. This tool breaks down any regex pattern into its components and explains each part in plain English.

How to Use

  1. Enter your regex pattern (without /delimiters/).
  2. Click 'Explain Regex' to parse and break down the pattern.
  3. Each token is color-coded by type: literal, quantifier, group, etc.
  4. Hover or scroll through the detailed explanation list.
  5. Use sample patterns to learn common regex patterns.
  6. Copy the full explanation for documentation or learning.

Why Use This Tool?

Understand complex regex patterns step by step
Learn regex syntax with visual breakdown
Debug patterns by seeing each component
Validate regex before using in code
Copy explanations for documentation
Sample patterns teach common use cases

Tips & Best Practices

  • Enter regex without surrounding slashes (/)
  • Quantifiers apply to the previous token
  • Groups can capture content or just structure logic
  • Anchors (^$) match positions, not characters
  • Character classes [...] match one character from set
  • Use non-capturing groups (?:) when you don't need the content

Frequently Asked Questions

What do the different token colors mean?

Purple = metacharacters like . (any char), orange = quantifiers (*+?{n}), blue = groups (...), green = anchors (^$), cyan = character classes [...], pink = escape sequences (\d\w), yellow = special (|). Literals (actual characters to match) are gray.

What's the difference between capturing and non-capturing groups?

Capturing groups (...) store matched content for later use (match[1], match[2]). Non-capturing groups (?:...) group patterns logically without storing. Use non-capturing when you don't need the matched content - it's more efficient and cleaner.

Why use lazy quantifiers (*? +?)?

Greedy quantifiers (*+) match as much as possible. Lazy quantifiers (*?+?) match as little as possible. Example: '<a>text</a>' with '<.+>' greedy matches the whole string, but '<.+?>' lazy matches just '<a>'. Use lazy when you want the shortest match.

What are lookahead and lookbehind?

Lookahead (?=...) matches if the pattern follows, without consuming it. Negative lookahead (?!...) matches if the pattern does NOT follow. Lookbehind (?<=...) checks what's before. These are zero-width assertions - they check conditions without including text in the match.

How do I test if my regex is valid?

This tool validates your regex when explaining. If it shows an error, the regex has syntax issues. Common errors: unmatched brackets, invalid escapes, or improper quantifier placement. Fix the syntax and try again.

Can this explain all regex features?

This tool explains most common regex syntax: anchors, quantifiers, character classes, groups, escapes, and alternation. Some advanced features like backreferences (\1), named groups, or mode flags may have simplified explanations. For full regex reference, check the regex-basics tutorial.

Related Tools