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 named fields from records and compute replacements for matched substrings.
How deep it goes
Explains search results, named-group access, optional groups, and substitution callbacks, but leaves position-related methods undetailed.
Examples
Demonstrates extracting names and phone numbers from records and changing matched integers to strings ending in `.0`.
What you can do after
Apply it via Python `re` to inspect named matches and generate replacements from each match.

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 →

Related concepts

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.