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

Updated on: 30-Jul-2019

93 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements