Matthias Huening mhuening at
Fri Jul 16 11:24:29 CEST 2004

hwlgw at (Will Stuyvesant) wrote in 
news:cb035744.0407160003.630701ee at

> 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 =, startposition)
	if res == None:
	startposition = res.start() + 1


More information about the Python-list mailing list