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

re.findall

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


Import

import re
from re import findall

Signature & Overview

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

Return a list of all non-overlapping matches in the string.

Usage

import re

assert re.findall(r"\d+", "a1 b22 c333") == ["1", "22", "333"]
# With 2+ capturing groups, findall returns a list of tuples
assert re.findall(r"(\w+)=(\d+)", "x=1 y=2") == [("x", "1"), ("y", "2")]

Gotchas

REPL Inspect

from re import findall
help(findall)

Linked from

Related notes