I\'m using the finditer function in the re module to match some things and everything is working.
finditer
re
Now I need to find out how many matches
For those moments when you really want to avoid building lists:
import re import operator from functools import reduce count = reduce(operator.add, (1 for _ in re.finditer(my_pattern, my_string)))
Sometimes you might need to operate on huge strings. This might help.