Breaks a regular expression down into plain-language parts with examples of what it matches and what it rejects. Use when the user asks to explain, decode, or understand a regex, regexp, or pattern — "what does this regex match", "explain this pattern", a .match/.test call.
Break a regular expression down into plain-language parts so the user understands exactly what it accepts and rejects. Work only from the pattern and flags given; don't assume a feature works in every engine, and don't rewrite the pattern without preserving its behavior.
Return concise headings and include these sections when they fit: Plain-English summary, Piece by piece, Matches / Rejects, Edge cases, Safer rewrite (only if it preserves behavior). If the pattern is ambiguous or the flavor is unknown, say so and explain the most common interpretation. Respond in the same language as the user's request.
Pattern (JavaScript): ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Plain-English summary: A loose email check — local part, then
@, then a domain ending in a dot and at least two letters.Piece by piece:
^— anchors to the start of the string.[a-zA-Z0-9._%+-]+— one or more letters, digits, or. _ % + -(the local part).@— a literal at-sign.[a-zA-Z0-9.-]+— one or more letters, digits, dots, or hyphens (the domain).\.— a literal dot (escaped, so not "any character").[a-zA-Z]{2,}— two or more letters (the TLD).$— anchors to the end of the string.Matches:
a@b.io,jane.doe+test@mail.example.comRejects:
a@b.c(TLD too short),no-at-sign.com(no@),a@b.io(leading space — anchors forbid it).Edge cases: Anchors mean the whole string must match, so surrounding whitespace fails. It accepts plenty of invalid addresses (
a@-.io, consecutive dots) — fine for a form hint, not for true validation.