Using Python 2.7, I was attempting to count the number of occurances of \'bob\' in the phrase \'bobbbobobboobobookobobbobbboj.\' To do this, I wrote the code below:
Guess i am a little bit late, but you can try this:
from re import findall def bobcount(word): return len(findall(r'(bob)', word.lower()))