I am trying to count the number of separated pairs of 1s in a string using a regex and re.findall() in Python.
The regex applied to the string 11110 should return 2 and applied to 01101 it should return 1.
My code is the following:
matches = len(re.findall(r'1[\w]+1', str1))
But applied to 110110 it returns 1 as it is only finding the substring 11011. I would expect it to also find the substring 101.
Is my regex wrong or is re.findall() not the function I should be using?