Regex Token-by-Token Explainer

Found a regex you don't understand? Paste it and get a token-by-token plain-English explanation — no more squinting at \d{2,4}[a-z]?.

—
Embed this tool on your website / blog No code required · Copy and paste
HTML Embed Code (iframe):
<iframe src="https://lucentool.com/regex-explainer" width="100%" height="650" style="border:1px solid #e5e0d8;border-radius:12px;max-width:850px;width:100%;" frameborder="0"></iframe>
<div style="font-size:12px;color:#78716c;margin-top:6px;font-family:sans-serif;">Powered by <a href="https://lucentool.com/regex-explainer" target="_blank" style="color:#c85a32;text-decoration:none;">Lucentool - Regex Token-by-Token Explainer</a></div>

Reading a regex

A regex is a sequence of tokens, each with a job: literal characters match themselves, character classes ([a-z]) match one of a set, quantifiers (+ * ? {2,4}) say how many, anchors (^ $ \b) pin positions, and groups ((…)) bundle and capture. The explainer walks every token left to right and says what the engine will try to match at that spot.

Common patterns decoded

Tips

Under the hood

explain() walks the pattern with tokenAt(), which recognises one construct at a time — an escape, a character class, a quantifier, a group, an anchor or a lookaround — and returns both the token length and a plain-language description. The loop advances by that length, so the explanation stays aligned with the source even when a construct spans several characters. escapeHtml() keeps angle brackets in the pattern from being rendered as markup.

Formats, sizes and other limits

This reads structure; it does not compile or run the pattern, and it does not build a full syntax tree — so scope questions (what exactly a quantifier applies to inside nested groups) are described in words rather than shown graphically. Invalid patterns are still tokenised, producing a confident-looking explanation of something that will not compile. Dialect differences such as PCRE-only escapes are described with common semantics, not your engine's.

Privacy: nothing is uploaded

The pattern is tokenised as plain text in the browser. It is not sent, not compiled against your data, and not stored between visits.

Frequently asked questions

Does it validate my regex?

No. It explains the tokens; syntax errors are only visible when a real engine tries to compile the pattern.

Why is the scope of a quantifier not shown?

Token-by-token scanning avoids building a tree, so nesting is explained in prose instead of a diagram.

Which flavour does it assume?

Common JavaScript/PCRE semantics. Anything engine-specific needs checking in that engine before you rely on it.