SyntaxStudy
Sign Up
Python Beginner 3 min read

re.findall

re.findall

re.findall() returns a list of all non-overlapping matches in the string.

Example
import re

text = "cat bat hat mat"
matches = re.findall(r"[cbhm]at", text)
print(matches)
# ["cat", "bat", "hat", "mat"]
Pro Tip

findall returns strings, not match objects — use finditer for match objects.