Group
group() is a regular-expression match-object method that returns the complete match or the text captured by a specified capturing group.
The Quick Python Book, Fourth Edition
group is a match-object method that retrieves the substring captured by a specified regular-expression group.
- How it is used
- Retrieves captured fields from regex matches for record parsing and replacement functions.
- How deep it goes
- Works through named-group syntax, match checking, optional captures, and callback retrieval; does not detail match-object internals.
- Examples
- Uses a surname-and-phone record parser and a number-to-decimal-string replacement.
- What you can do after
- Apply it via Python’s `re` module to extract named fields and construct replacement strings from matches.
Read how The Quick Python Book, Fourth Edition explains group →
Python How-To
A group method is a regular-expression match operation that returns the substring captured by specified groups or the complete match when no group number is supplied.
- How it is used
- Retrieves complete matches or selected captured fields for downstream text processing.
- How deep it goes
- Explains complete, numbered, and named retrieval through worked examples, while warning that positional numbering becomes error-prone.
- Examples
- Demonstrates extracting words from a phrase and task IDs, titles, and descriptions from structured text.
- What you can do after
- Apply Python's regular-expression Match API to retrieve complete, numbered, or named captured text.
Related concepts
- match objectused by · A match object is a regular-expression result structure containing matched text and providing access to its location and captured groups.
- regex groupinguses · A regex capturing group is a parenthesized regular-expression subpattern whose matched text is retained for separate access or reference.
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.

