Computer >> Computer tutorials >  >> Programming >> Python

How can I find all matches to a regular expression in Python?


We use re.findall or re.finditer methods to find all matches to a regular method.

re.findall(pattern, string) returns a list of matching strings.

re.finditer(pattern, string) returns an iterator over MatchObject object