Regex Explainer
Help & Examples
This enhanced Regex Explainer:
- Groups logical tokens (e.g. non‑capturing vs. capturing groups).
- Handles character classes as single units.
- Explains quantifiers in context.
- Still provides pattern stats and a cheat sheet.
Core Example
Input:
`^` → start‑of‑string anchor
`(?:https?)` → non‑capturing group matching “http” or “https”
`://` → literal “://”
`([\w\-.]+)` → capturing group: one or more word‑chars, hyphens, or dots (the domain)
`/?` → optional slash
`$` → end‑of‑string anchorPattern Statistics for Above
| Length | 23 |
|---|---|
| Capturing Groups | 1 |
| Non‑capturing Groups | 1 |
| Positive Lookahead | 0 |
| Total Quantifiers | 3 |
Quick‑Reference Cheat Sheet
`^` → start anchor | `$` → end anchor
`\d` → digit | `\w` → word char
`+` → one or more | `*` → zero or more
`?` → zero or one | `{n,m}` → range quantifier
`( )` → capturing | `(?: )` → non‑capturing
`(?= )` → lookahead | `(?<= )` → lookbehind
`|` → alternation | `.` → any char
When to Use
– Audit complex patterns at a glance.
– Document regex in code reviews.
– Teach teammates without regex experience.