Python regex `finditer` function

Python regex finditer() function explained with examples.

Python string finditer

finditer() is a powerful function in the re module. It returns an iterator yielding MatchObject instances over all non-overlapping matches for the RE pattern in string.


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

Here the string is scanned left-to-right, and matches are returned in the order found. Empty matches are included in the result unless they touch the beginning of another match.

Get hands-on with 1200+ tech skills courses.