re.findall
re.findall() returns a list of all non-overlapping matches in the string.
re.findall() returns a list of all non-overlapping matches in the string.
import re
text = "cat bat hat mat"
matches = re.findall(r"[cbhm]at", text)
print(matches)
# ["cat", "bat", "hat", "mat"]
findall returns strings, not match objects — use finditer for match objects.