Interactive capture-group debugger

Regex Capture Group Tester & Explorer

Paste a JavaScript regular expression and test text to inspect exactly what each capture group contains. See full matches, numbered captures, named groups, and character ranges without sending your input to a server.

Private by design: patterns and test text are evaluated locally in your browser.
//

Try flags such as g, i, m, s, or u. With no g or y, JavaScript returns only the first match.

Live result

Captured groups

3 matches

Match 1

characters 06
Ada 37
Group $1[0, 3)
Ada
Group $2[4, 6)
37
Named groups
name[0, 3)
Ada

Match 2

characters 715
Linus 55
Group $1[7, 12)
Linus
Group $2[13, 15)
55
Named groups
name[7, 12)
Linus

Match 3

characters 1624
Grace 85
Group $1[16, 21)
Grace
Group $2[22, 24)
85
Named groups
name[16, 21)
Grace

Numbered vs named capture groups

Parentheses such as (\\d+) create numbered captures in left-to-right opening-parenthesis order. JavaScript named groups use (?<name>...), which lets application code read match.groups.name instead of relying only on a numeric position.

/(?<year>\d{4})-(\d{2})-(\d{2})/
// full match: 2026-08-17
// $1 / year: 2026
// $2: 08
// $3: 17

When not to capture

Use (?:...) when parentheses exist only to control precedence or apply a quantifier. Non-capturing groups keep the result easier to reason about and prevent later edits from unexpectedly shifting numbered group positions.

If a pattern is difficult to understand even with this explorer, move to the Regex Debugger or test the full expression in the Regex Tester.

Common capture-group debugging checks

Optional groups

A group inside ? or an unmatched alternative may legitimately be undefined for a particular match.

Group numbering

Nested capturing parentheses still consume group numbers. Convert structure-only parentheses to (?:...) when captures are not needed.

Global matching

The g flag returns repeated matches. Each match has its own capture values, so inspect groups per match rather than assuming one global value.

Frequently asked questions

What is a capture group in regex?

A capture group is a parenthesized part of a regular expression whose matched text is stored separately from the full match. Numbered groups use parentheses such as (\d+), while named groups use syntax such as (?<year>\d{4}) in JavaScript.

What is the difference between a capture group and a non-capturing group?

A capturing group stores its matched substring for later inspection or backreferences. A non-capturing group, written (?:...), groups alternatives or quantifiers without creating a numbered capture.

Why is a capture group undefined?

Optional groups and alternatives do not have to participate in every match. When a group does not participate, JavaScript returns undefined for that capture.

Does this explorer use JavaScript regex behavior?

Yes. Patterns are evaluated with the browser JavaScript RegExp engine, so group syntax, flags, lookbehind support, Unicode behavior, and backreferences follow ECMAScript semantics.