What\'s the best way to count the number of occurrences of a given string, including overlap in Python? This is one way:
def function(string, str_to_search_f
That can be solved using regex.
import re def function(string, sub_string): match = re.findall('(?='+sub_string+')',string) return len(match)