liveBook · Manning

Match object

A match object is a regular-expression result structure containing matched text and providing access to its location and captured groups.

How 2 Manning books explain it

The Quick Python Book, Fourth Edition

A match object is a Python regular-expression result object that records the substring matched and provides access to captured groups and match positions.

How it is used
Uses match objects to extract captured text and provide context for replacement functions.
How deep it goes
Demonstrates named-group extraction and replacement callbacks, but only mentions additional match information and substring positions.
Examples
Uses name-and-phone records with an optional middle name and a callback that appends .0 to integer matches.
What you can do after
Apply Python's re module to retrieve named captures and construct match-dependent replacement strings.

Read how The Quick Python Book, Fourth Edition explains match object →

Python How-To

A match object represents one regular-expression match and provides information about that match, such as its location.

How it is used
Uses successful regular-expression searches to inspect matched text, positions, and captured fields.
How deep it goes
Explains creation, truthiness, core inspection methods, numbered groups, and iteration, without descending into implementation internals.
Examples
Demonstrates matched text and spans, numbered groups, and parsing structured task records.
What you can do after
Diagnose regular-expression results by testing truthiness and printing matched text, captured groups, and character positions.

Read how Python How-To explains match object →

Also covered in

What to know first

Related concepts

Questions about match object

What is match object?

A match object is a regular-expression result structure containing matched text and providing access to its location and captured groups.

Which Manning books explain match object?

The Quick Python Book, Fourth Edition and Python How-To.

What should I know before learning match object?

Manning books that teach match object usually introduce regular expression and function first.

What are the parts of match object?

Match object includes match array.

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.