a simple regex question

Paddy paddy3118 at netscape.net
Sun Apr 2 10:55:41 EDT 2006


John Salerno wrote:
> But would findall return this match: aMNHiRFLoDLFb  ??
>
> There are actually two matches there, but they overlap. So how would
> your write an RE that catches them both?

I remembered the 'non-consuming' match (?+...) and a miniute of
experimentation gave
the following.

>>> import re
>>> s ="aMNHiRFLoDLFb"
>>> re.findall(r'[A-Z]{3}([a-z])(?=[A-Z]{3})', s)
['i', 'o']
>>> 

- Paddy.




More information about the Python-list mailing list