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
- Uses named captures to retrieve fields after a search or inside a substitution callback.
- How deep it goes
- Demonstrates named-group extraction, optional-group handling, and callable replacement without detailing numeric indexing.
- Examples
- Extracts names and phone numbers from records and adds .0 to digit sequences.
- What you can do after
- Apply it via Python's re module to extract named captures and construct replacement strings.
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.
What to know first
- regular expressionA regular expression is a formal pattern notation that describes sets of strings and specifies how text can be matched, searched, or transformed.
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.
Questions about group
What is group?
group() is a regular-expression match-object method that returns the complete match or the text captured by a specified capturing group.
Which Manning books explain group?
The Quick Python Book, Fourth Edition and Python How-To.
What should I know before learning group?
Manning books that teach group usually introduce regular expression first.
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.

