liveBook · Manning

Re.search

re.search is a Python re-module function that searches a string for the first match of a regular-expression pattern and returns a match object or None.

How 2 Manning books explain it

The Quick Python Book, Fourth Edition

search is a regular-expression pattern method that looks for the first match of a pattern within a string and returns a match object or None.

How it is used
Finds matching text in strings, either to test a condition or to extract fields from a record.
How deep it goes
Works through compiled-pattern searches and match-object extraction, but leaves advanced search controls to documentation.
Examples
Counts file lines containing `hello` and extracts names and phone numbers from matching records.
What you can do after
Apply it via Python’s `re` module to test strings and retrieve named fields from successful matches.

Read how The Quick Python Book, Fourth Edition explains re.search →

Python How-To

How it is used
Finds the first occurrence of a regular-expression pattern anywhere in a string.
How deep it goes
Explains direct and compiled calls, Match objects, positions, conditionals, and differences from match, findall, and finditer.
Examples
Uses digit-word patterns, matched text, spans, and direct calls on strings.
What you can do after
Apply it via Python's re module to locate a match and inspect its text and character positions.

Read how Python How-To explains re.search →

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.