counting number of (overlapping) occurances

John weekender_ny at yahoo.com
Fri Mar 10 00:21:49 EST 2006


I have two strings S1 and S2. I want to know how many times
S2 occurs inside S1.

For instance

if S1 = "AAAA"
and S2 = "AA"

then the count is 3. Is there an easy way to do this in python?
I was trying to use the "count" function but it does not do
overlapping counts it seems.

Thanks,
--j




More information about the Python-list mailing list