Regex grouping
A regex capturing group is a parenthesized regular-expression subpattern whose matched text is retained for separate access or reference.
The Well-Grounded Rubyist, Fourth Edition
A submatch is the substring matched by a parenthesized subpattern within a regular-expression match.
- How it is used
- Isolates useful substrings within regular-expression matches for field extraction and string substitution.
- How deep it goes
- Works through numbering, nested and named groups, optional captures, non-capturing groups, and retrieval through MatchData.
- Examples
- Uses comma-separated personal fields, a phone number, nested groups, scanned names, and a corrected letter transposition.
- What you can do after
- Applies it via Ruby’s match, scan, sub, and gsub to extract fields and reuse captures in replacements.
Read how The Well-Grounded Rubyist, Fourth Edition explains regex grouping →
Secrets of the JavaScript Ninja, Second Edition
A regular-expression subgroup whose matched text is recorded for later access or reference.
- How it is used
- Extracts matched substrings for later access, backreferences, and replacement logic.
- How deep it goes
- Works through capture positions and the different results of local match, global match, and repeated exec calls.
- Examples
- Uses CSS translateY extraction, HTML-tag matches, and dashed-string camel casing.
- What you can do after
- Apply captures via String.match, RegExp.exec, or String.replace to extract or transform matched text.
Read how Secrets of the JavaScript Ninja, Second Edition explains regex grouping →
Tiny Python Projects: Learn coding and testing with puzzles and games
A capture group is a parenthesized subpattern in a regular expression whose matched text is retained for later retrieval.
- How it is used
- Uses parentheses to retain matched substrings for word transformation, text splitting, and later retrieval.
- How deep it goes
- Explains group retrieval, numbering, optionality, nesting, and non-capturing syntax through runnable examples.
- Examples
- Demonstrates consonant-vowel word parsing, capitalization-preserving transformations, captured separators, and optional nested patterns.
- What you can do after
- Apply it via Python's re module to extract, reuse, or preserve selected portions of matched text.
The Quick Python Book, Fourth Edition
A capturing group is a parenthesized regular-expression subpattern whose matched text is retained for later retrieval.
- How it is used
- Groups alternatives and optional fields, then retains named fields for extraction from matched name-and-phone records.
- How deep it goes
- Works through grouping, optionality, named capture, and retrieval with `group()`; leaves broader regex subtleties to `re` documentation.
- Examples
- Uses `(h|H)ello`, optional phone area codes, and a name-and-phone record parser with named fields.
- What you can do after
- Apply it via Python `re` to match optional fields and retrieve named values from a successful search.
Read how The Quick Python Book, Fourth Edition explains regex grouping →
Modern C, Third Edition
A capture is a lambda specification identifying variables from the surrounding scope that are made available inside the lambda.
- How it is used
- Uses lambda captures to make surrounding expressions available inside a lambda used to implement macros.
- How deep it goes
- Defines init-capture syntax and its inferred, const-qualified semantics, but leaves writable captures beyond scope.
- Examples
- Uses pointer init-captures in a `SWAP` macro to bring its operands into a lambda.
- What you can do after
- Understand how init-captures make surrounding expressions available inside a lambda.
Python How-To
A capturing group is a delimited subexpression in a regular expression whose matched substring is retained for later access.
- How it is used
- Extracts individual fields from matched text for further processing.
- How deep it goes
- Explains parentheses, group numbering, and retrieval; flags numbering risks but does not detail named-group mechanics.
- Examples
- Uses a comma-separated phrase and task records with ID, title, and description fields.
- What you can do after
- Apply Python regular-expression matching to extract separate fields from text.
Related concepts
- noncapturing groupcontrasts with · A noncapturing group is a parenthesized regular-expression subpattern that groups matching behavior without storing its matched text as a capture.
- regular expressionpart of · A formal pattern notation that describes sets of strings and enables text to be matched, searched, extracted, or transformed.
- backreferenceused by · A backreference is regular-expression or replacement-string notation that refers to text captured by a capturing group.
- conditional matchused by · A conditional match selects between regular-expression subexpressions according to whether a specified capture was found.
- exec methodproduced by · The JavaScript RegExp exec method searches a string for a match and returns a match result with captures or null if no match is found.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.





