Regex Explainer
Decompose regular expressions into fragments and explain each part in plain natural language
Enter a regex pattern with or without /.../ delimiters. Flags like g, i, m are detected automatically.
What is the Regex Explainer?
The Regex Explainer decomposes any regular expression into its individual parts and explains each fragment in plain natural language. Whether you're trying to understand a complex legacy regex or debugging a pattern you just wrote, this tool breaks it down into groups, quantifiers, character classes, anchors, and escape sequences with clear descriptions.
How to Use
- Paste or type your regular expression in the input field
- Use either plain format (e.g.,
\d{3}-\d{4}) or JavaScript delimiters (e.g.,/\d{3}-\d{4}/gi) - The tool automatically explains each fragment as you type
- Review the visual decomposition showing what each part does
- Check for performance warnings about potentially dangerous patterns
Example: Email Validation Regex
A common email validation pattern broken down:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
The tool explains that ^ anchors to the start, [a-zA-Z0-9._%+-]+ matches
one or more word characters and special email characters, @ is a literal at-sign,
and {2,} requires at least 2 letters for the domain extension.
Example: Phone Number Pattern
/\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/g This matches US phone numbers in various formats: (555) 123-4567, 555.123.4567, 555-123-4567. The tool explains each optional group and quantifier clearly.
Performance Issue Detection
The tool detects patterns that can cause catastrophic backtracking — a condition where the regex engine takes exponential time to process certain inputs. Common problems include:
- Nested quantifiers —
(a+)+causes exponential backtracking - Overlapping alternatives —
(a|a)+matches the same input in multiple ways - Unanchored greedy patterns —
.*without^forces many retries
Fragment Types Explained
- Groups — Capturing
(...), non-capturing(?:...), named(?<name>...), lookahead(?=...), lookbehind(?<=...) - Quantifiers —
*(0+),+(1+),?(0-1),{n},{n,m} - Character Classes —
[abc],[a-z],\d,\w,\s - Anchors —
^,$,\b(word boundary) - Alternation —
|(OR operator) - Escape Sequences —
\n,\t,\x41,\u0041
Privacy and Security
All analysis happens entirely in your browser using JavaScript. Your regular expressions are never transmitted to any server. No data is stored, logged, or shared.
Frequently Asked Questions
What does the Regex Explainer do?
The Regex Explainer decomposes a regular expression into its individual fragments — groups, quantifiers, character classes, anchors, and escape sequences — and explains each one in plain natural language. It also detects potential performance issues like catastrophic backtracking patterns.
What input format does it accept?
You can enter a regex either as a plain pattern (e.g., \d{3}-\d{4}) or using JavaScript-style delimiters with flags (e.g., /\d{3}-\d{4}/gi). The tool automatically extracts the pattern and flags from either format.
What is catastrophic backtracking?
Catastrophic backtracking occurs when a regex engine explores exponentially many paths through the input due to nested quantifiers or overlapping alternatives. Patterns like (a+)+ or (a|a)+ can cause the engine to hang on non-matching inputs. The tool detects these patterns and suggests safer alternatives.
What types of fragments does it identify?
The tool identifies groups (capturing, non-capturing, named, lookahead, lookbehind), quantifiers (*, +, ?, {n}, {n,m}), character classes ([...], \d, \w, \s), anchors (^, $, \b), alternation (|), escape sequences, and backreferences.
Does this tool test the regex against sample text?
No. The Regex Explainer focuses on explaining what the regex does — it decomposes and describes the pattern. To test a regex against actual text and see matches, use the Regex Tester tool.
Is my regex sent to a server?
No. All analysis happens entirely in your browser using JavaScript. Your regular expression is never transmitted to any server. No data is stored, logged, or shared.
What performance issues does the tool detect?
The tool detects nested quantifiers (e.g., (a+)+), overlapping alternatives with quantifiers, unanchored .* patterns, repeated capturing groups, adjacent identical quantifiers, and excessively long patterns. Each issue includes a severity level and a recommendation for fixing it.
Can it explain regex flags?
Yes. When you provide a regex with flags (e.g., /pattern/gim), the tool extracts and reports the flags. Common flags include g (global), i (case-insensitive), m (multiline), s (dotAll), u (Unicode), and y (sticky).
What is the difference between the Regex Explainer and the Regex Library?
The Regex Explainer analyzes any regex you provide and explains its components. The Regex Library provides a curated collection of common patterns (email, UUID, IPv4, etc.) with pre-written explanations and test examples you can browse and copy.