Skip to content
UniKit

Regex structure analyzer

Parse a JavaScript regular expression into a structure tree: literals, character classes, anchors, back references, groups and quantifiers, with capture numbering (including named groups), lookaround and quantifier counts, plus a RegExp syntax check. A text structure view, no image rendering.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Enter the pattern only, without the surrounding slashes or flags; the syntax is checked with RegExp first.

Parsed structure

Parsed character by character with JavaScript semantics; quantifiers are greedy by default and `{2,3}?` is lazy (JavaScript has no possessive quantifiers).

Enter a pattern to see its structure tree

Items: 0 · Capture groups: 0 · Lookarounds: 0 · Nesting depth: 0

What this tool does

  • Read a long inherited regular expression: how many groups it has, which parts are lookarounds and what each quantifier applies to
  • Map capture numbers to match indices, including named captures
  • Spot quantifiers written on the wrong level and check whether each one is greedy, lazy or possessive

Example

Input

\d{2,4}

Output

Pattern: /\d{2,4}/
Top-level branches: 1
Items: 1 (1 with quantifiers, 0 lookarounds, 0 back references)
Capture groups: 0
Nesting depth: 1

Structure tree:
sequence
└─ character class \d (digits [0-9])  quantifier {2,4} (2 to 4, greedy)

Item, quantifier, lookaround and back-reference counts all come from the real parse.

Frequently asked questions

Does it draw a diagram or export SVG / PNG?

No. The output is a text structure tree (indented, branch by branch) plus counts; nothing is rendered and there is no image export.

Which regular expression constructs are supported?

Literals, escapes (\d \w \s \xHH \uHHHH \u{...} \p{...}), character classes, dot, anchors (^ $ \b \B), quantifiers (* + ? {n} {n,} {n,m} and the lazy form {n,m}?), plain, non-capturing and named groups, lookarounds, and back references \1 / \k<name>. JavaScript has no possessive quantifiers (a*+) or atomic groups ((?>…)) — both fail to compile, and this tool reports the same error.

What happens with invalid syntax?

The pattern is first compiled with `new RegExp(pattern)`; a failure reports "invalid regular expression syntax". Unclosed `(` or `[` and dangling quantifiers such as `a**` all take that path.

Why do the group numbers differ from mine?

Captures are numbered strictly by opening-parenthesis order; lookarounds, `(?:…)` and atomic groups take no number, which matches JavaScript match result arrays.

Any limit on the pattern?

Enter the pattern only, without slashes or flags (the parser treats flags as literals), and keep it under 2000 characters — longer input errors instead of being truncated.

Keywords:regex railroadlookaroundRegex structure analyzeroffline

Related tools