12 chars · 1 line
5 chars · 1 line
12 chars · 1 line
5 chars · 1 line
Regex capture behavior
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
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.
The two groups capture the first and last name independently.
([A-Za-z]+) ([A-Za-z]+)
Ada Lovelacecapture 1: Ada
capture 2: LovelaceCommon questions
No. The complete match is separate; capture 1 is the first parenthesized capturing group.
VetaTool represents an unmatched numbered capture as null in Match All output.
Yes. JavaScript replacement strings can reference numbered captures with tokens such as $1 and $2.
Debugging a specific Regex issue? Browse Regex troubleshooting.