Bug in regular expressions ?

Bernhard Herzog bh at intevation.de
Fri May 17 11:56:50 EDT 2002


Christophe Delord <christophe.delord at free.fr> writes:

> Hi,
> 
> I thought that regular expressions were greedy, so that the longuest match is returned by match().
> Consider these expressions : 'a|aa', 'aa|a' and 'aa?'
[...]
> So A|B and B|A are not always equivalent. When A and B match, B is
> ignored even if the matched text is longer. Is this a bug in the re
> module?

No. It works as documented.

> Is there a way to tell re to be "totaly greedy"?

List the longer alternatives first. Other than that, I don't know.

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                           http://www.mapit.de/



More information about the Python-list mailing list