0Pricing
Python Academy · Lesson

Using re.match, re.search, re.findall

Apply core re functions to find patterns in strings.

Introduction

The re module provides several functions for applying patterns to strings.

re.match() — Start of String

re.match(pattern, string) matches only at the BEGINNING of the string. Returns a Match object or None.
import re
print(re.match(r'\d+', '123abc'))  # match
print(re.match(r'\d+', 'abc123'))  # None

All lessons in this course

  1. Regex Fundamentals
  2. Using re.match, re.search, re.findall
  3. Groups and Named Captures
  4. re.sub, Flags, and Compiled Patterns
← Back to Python Academy