Overlapping matches
Ant
antroy at gmail.com
Sun Apr 1 16:58:12 EDT 2007
On Apr 1, 9:38 pm, Rehceb Rotkiv <reh... at no.spam.plz> wrote:
> In the re documentation, it says that the matching functions return "non-
> overlapping" matches only, but I also need overlapping ones. Does anyone
> know how this can be done?
Something like the following:
import re
s = "oooooooo"
p = re.compile("oo")
out = []
while pos < endpos:
m = p.search(s, pos)
if not m:
break
out.append(m)
pos = m.start() + 1
More information about the Python-list
mailing list