Regex Capture Groups – Inspect Numbered Captures Online

Local only

Use Match All to see exactly what each parenthesized capture group returns for a JavaScript regular expression.

12 chars · 1 line

5 chars · 1 line

Pattern matched the inputFlags: g

Regex capture behavior

How to inspect capture groups in a JavaScript regex

Parentheses do more than group tokens: ordinary (...) groups also capture the substring they matched. The matcher above preloads a first-name / last-name example and shows the complete match alongside capture 1 and capture 2. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • Numbered capture inspection
  • Match indexes
  • Structured Match All output
  • JavaScript RegExp semantics
  • No upload required
  • Browser-local processing

Steps

  1. Wrap the subexpressions you need to reuse or inspect in ordinary parentheses.
  2. Run Match All against representative text and inspect the captures array for each result.
  3. Use a non-capturing group when parentheses are needed only for precedence and no captured value is required.

Capture numbering follows opening parentheses

In JavaScript, ordinary capturing groups are numbered from left to right by opening parenthesis. Match All exposes those values in order while keeping the full match and its input index separate.

Numbered capture group example

The two groups capture the first and last name independently.

Pattern and input

([A-Za-z]+) ([A-Za-z]+)
Ada Lovelace

Captured values

capture 1: Ada
capture 2: Lovelace

Common questions

Frequently asked questions

Does the complete regex match count as capture 1?

No. The complete match is separate; capture 1 is the first parenthesized capturing group.

What happens when an optional group does not participate?

VetaTool represents an unmatched numbered capture as null in Match All output.

Can captures be reused during replacement?

Yes. JavaScript replacement strings can reference numbered captures with tokens such as $1 and $2.

Debugging a specific Regex issue? Browse Regex troubleshooting.