Dev TooloraLocal dev tools

> Text

Regex Explainer

Break a JavaScript regular expression into an indented tree of plain-English explanations, with a warning for nested unbounded quantifiers.

Runs locallyWorks offline
Auto-run
Back to results
Input

Source data

Output

Result

Your result will appear here.

Tool guide

About this tool.

  • A regular expression packs a search rule into a few symbols, which makes it quick to write and slow to read. This tool parses a JavaScript pattern and prints it as a tree: one line per piece, indented by nesting, with a plain-English sentence next to each piece.
  • The parser follows the ECMAScript 2025 grammar: groups, named groups, lookahead and lookbehind, modifier groups such as (?i:…), quantifiers, character classes, Unicode property escapes and the v-flag set operations. The pattern is only parsed; nothing is matched against text.
  • Everything runs in your browser. You can paste a bare pattern or a whole /pattern/flags literal copied from code.

  • Read a pattern you inherited before you change it.
  • Check that a pattern you wrote groups and repeats what you meant.
  • Spot a nested quantifier that can backtrack heavily on input that does not match.
  • Learn what a lookbehind, a v-flag set or a modifier group means.

Paste a regular expression into the input. A bare pattern such as ^(?<year>\d{4})$ works, and so does a literal copied from code such as /^(?<year>\d{4})$/u. Type the flags in the Flags field when you paste a bare pattern.

The result is a header with the flags in words, then one line per piece of the pattern. Groups and classes print their opening bracket, their contents one level deeper and a closing line. Quantifiers are folded into the line of the piece they repeat, for example a digit exactly 4 times.

The summary counts the explained nodes and the warnings. The one structural warning flags an unbounded quantifier on a group that contains another unbounded quantifier, which can backtrack heavily on input that does not match. The JSON file lists every node with its start, end and explanation.

A pattern that this browser rejects, or one the parser does not know, gives a short error with an index instead of the raw engine message. Backreference numbers and group names are explained, not resolved against text.

  • ^(?<year>\d{4})-(\d{2})$ → a named group "year" (group 1) and a second capture group, each with exactly the digit count.
  • /a\/b/gi → the literal is split at its last slash; the pattern a\/b is explained with flags g and i.
  • ^.+?$ with flag m → Start of a line, any character one or more times as few times as possible, End of a line.
  • (?<=\$)\d+ → Preceded by the character "$", then a digit one or more times.
  • [[a-z]--[aeiou]] with flag v → one character from the set: a to z, Minus, a set of vowels.
  • ((a+)+)$ → a warning for the nested unbounded quantifier at index 5.

  • Processing is local; nothing is uploaded.
  • Limits: a pattern of 10,000 UTF-16 units, 10,000 nodes, nesting depth 64 and output of 500,000 characters.
  • Positions in the JSON file are zero-based UTF-16 offsets into the pattern, with an exclusive end.
  • Plain characters next to each other are shown as one line, so abc reads as The characters "abc".
  • An escape is explained by code point, for example \n as U+000A, with the character in quotes when it is printable; an escaped punctuation mark such as \$ or \/ reads as the character itself.
  • Only the v flag allows nested classes, -- and && set operations and \q{…} strings.

FAQ

Questions about Regex Explainer

Should I paste the slashes and flags?

Both. A selection such as /\d+/gi is split at its last slash and the letters after it become the flags. If the Flags field also has text, the pasted flags win and the summary says so.

Why does a valid-looking pattern fail?

The tool parses the ECMAScript 2025 grammar itself and then lets this browser compile the pattern. If the parser accepts a pattern the browser rejects, the error says the runtime may be older than the syntax.

What is the nested quantifier warning?

An unbounded quantifier, such as + or *, wraps a group that holds another one, as in (a+)+. On text that almost matches, the engine can try exponentially many splits. Bound the inner part or remove the nesting.

Does it test the pattern on my text?

No. The explainer only parses the pattern and needs no subject text. To see matches and captures on real text, open Regex Tester, which runs the pattern in an isolated worker.

How are capture groups numbered?

Groups are numbered by their opening parenthesis from left to right, as the engine does. Named groups count too, and a repeated name in different alternatives keeps a distinct number each time.

Continue with

Regex TesterInspect JavaScript regex matches, capture groups and replacements with explicit flags and an isolated execution limit.Find & ReplaceReplace literal text or JavaScript regex matches with explicit replacement semantics, before/after inspection and isolated execution.Pattern ExtractorExtract emails, URLs, IP addresses, numbers, hashtags or a custom regex capture group from text, one match per line.