Account

What new tool do you want?

Developer Tools

Regex Explainer (Explain a Regular Expression)

Paste a regular expression and get a plain-English, token-by-token explanation — character classes, groups, lookarounds, quantifiers, anchors and flags. Works with JavaScript and PCRE-style syntax. No AI, instant.

How to use

  1. 1Paste a pattern, with or without /slashes/flags.
  2. 2Read the explanation line by line — indented lines are inside a group.
  3. 3Test it on real text with our Regex Tester.

Frequently asked questions

Which regex flavours are supported?

JavaScript syntax, which covers most of what PCRE, Python and Java use (groups, lookarounds, classes, quantifiers, named groups, Unicode properties). Flavour-specific features like recursion or conditionals aren't explained.

Why does it say my regex is invalid?

The pattern is checked with your browser's regex engine first. Common causes are unbalanced parentheses or brackets, or a quantifier with nothing before it.

Is there a cron explainer too?

Yes — see our Cron Expression Explainer for crontab schedules.

Worked example: Regex Explainer

Feed it /(?<year>\d{4})-[^a-z]+?/gi and it breaks the pattern into exactly four lines: (?<year> → "start of capture group 1 named 'year'", \d{4} → "a digit (0-9) — exactly 4 times", the literal -, and [^a-z]+? → "any character except: a–z — one or more times, as few as possible (lazy)." It also separately reports Flags: global (find all matches); case-insensitive and Capture groups: 1 — pulled from the trailing /gi and the single named group respectively. That lazy quantifier explanation matters: +? (lazy) and + (greedy) look almost identical but behave very differently on real text, and conflating them is one of the most common regex debugging mistakes.

Why this is purely mechanical, not AI-assisted

The explainer walks the pattern character by character with a real token parser — tracking group depth for indentation, recognizing escape sequences, character classes, named groups and lookarounds by their exact syntax — and translates each recognized token into a fixed English description. There's no language model involved and no guessing about intent: the same regex always produces the exact same explanation, deterministically, which is precisely why it can run instantly in your browser the moment you stop typing rather than needing a network round-trip.

What "invalid" actually means here, and what it can't explain

Before attempting to explain anything, the tool constructs an actual `new RegExp(pattern, flags)` using your browser's native regex engine — if that throws (unbalanced parentheses, a quantifier with nothing before it, an unclosed character class), the tool reports the engine's own error rather than guessing what you meant. On the other side, the explainer deliberately covers JavaScript-flavor syntax, which overlaps heavily with PCRE, Python and Java but not perfectly — flavor-specific features like PCRE's recursive patterns or .NET's balancing groups aren't part of JavaScript's regex engine and won't be recognized here, since there's no universal 'regex' standard to parse against.

A blank box stays blank, and the flags line appears only when I used flags

An empty box produces an empty result, not an error. A pattern that will not compile says "Invalid regular expression" and then the reason, without repeating that phrase from the underlying message. The last line always reports how many capture groups were found, and zero means there were none. A flags line is added only when the pattern actually has flags. The placeholder is written with slashes and an i flag, so the flags line shows up on the sample. I remove the slashes when I want the explanation of the pattern alone.

Related tools

More: Developer Tools