Is there a way that I can find out how many matches of a regex are in a string in Python? For example, if I have the string \"It actually happened when it acted out of
\"It actually happened when it acted out of
I know this is a question about regex. I just thought I'd mention the count method for future reference if someone wants a non-regex solution.
>>> s = "It actually happened when it acted out of turn." >>> s.count('t a') 2
Which return the number of non-overlapping occurrences of the substring