liveBook · Manning

Group

group() is a regular-expression match-object method that returns the complete match or the text captured by a specified capturing group.

How 2 Manning books explain it

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.

Read how Python How-To explains group →

What to know first

Related concepts

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.