On this page
  1. re.search
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

re.search

Prev: re.RegexFlag | Up: re | Next: re.split
Rel: re.compile, re.error, re.escape, re.findall
Ref: docs.python.org — re.search
Tags: #public #python3 #stdlib #re


Import

import re
from re import search

Signature & Overview

re.search(pattern, string, flags=0)

Scan through string looking for a match to the pattern, returning a Match object, or None if no match was found.

Usage

import re

m = re.search(r"v(\d+\.\d+)", "release v2.5 ready")
assert m is not None and m.group(1) == "2.5"

Gotchas

REPL Inspect

from re import search
help(search)

Linked from

Related notes