(Will Stuyvesant) wrote in
news: om:
> A question about the findall function in the re module, and I also
> would be happy with pointers to online documentation with which I
> could have found a solution myself (if it even exists!).
>
The problem is that the strings you want to find are overlapping.
This should get you started:
import re
s = "i or j or k or grr"
pat = re.compile(r'\w+ or \w+')
startposition = 0
while 1:
res = pat.search(s, startposition)
if res == None:
break
startposition = res.start() + 1
print res.group()
Matthias