Isn't re.findall supposed to find all?
Rodrigo Senra
rodsenra at correionet.com.br
Fri Nov 10 21:57:57 EST 2000
June Kim wrote:
>
> But my question still remains; I want to find a substring
> that starts with a specific string, say XYZ and ends with
> another specific string, say QPR, but hasn't got a string,
> LMN in between the opener and the closer.
>
> e.g. XYZ....(any length of letters but no LMN here).....QPR
>
> Could any one enlighten me kindly?
My beacon points to: ;o)
'XYZ....(any length of letters but no LMN here).....QPR XYZ bla NML QPR'
>>> p = re.compile(r'(XYZ[\w\s]*?[^LMN][\w\s]*?QPR)')
>>> print p.findall(z)
['XYZ bla NML QPR']
Where:
r'(XYZ[\w\s]*?[^LMN][\w\s]*?QPR)
raw=head + non-greedy-stuff + avoid-LMN + non-greedy-stuff + tail
regards
Rod
--
Rodrigo Senra
Computer Engineer (GPr Sistemas Ltda) rodsenra at correionet.com.br
MSc Student of Reflection (IC- UNICAMP) Rodrigo.Senra at ic.unicamp.br
http://www.ic.unicamp.br/~921234 (see also http://www.gpr.com.br)
More information about the Python-list
mailing list