What it does
Parentheses capture: group 1, group 2 and so on keep the text they matched, as strings with leading zeros intact.
How to use it
- Load the example.
- Open a match to see group 0 (the whole match) and the numbered groups.
- Check the counterexample.
Verified example
Example
Text "AB-007"
([A-Z]{2})-(\d{3}) Result: "AB-007"; groups "AB", "007"
([A-Z]{2})-(\d{3}) Result: "AB-007"; groups "AB", "007"
([A-Z]{2})-(\d{3}) Result: "AB-007"; groups "AB", "007"
([A-Z]{2})-(\d{3}) Result: "AB-007"; groups "AB", "007"
Counterexample
Text "A-7"
([A-Z]{2})-(\d{3}) Result: no match
([A-Z]{2})-(\d{3}) Result: no match
([A-Z]{2})-(\d{3}) Result: no match
([A-Z]{2})-(\d{3}) Result: no match
Recorded by running fixture FX-S04 on : rp.js@1 on Node v24.21.0 (V8), v24.21.0, CPython 3.14.2 (Pyodide 314.0.7), PCRE2 10.48, go1.27.1. JavaScript results come from the rp.js@1 core on Node’s V8; your browser runs the same core.
Engines
- Capture numbering by opening parenthesis is the same in all four engines.
Limits
- A group that did not take part in a match is null, which is different from an empty string.