sre \Z bug or feature?

Pearu Peterson pearu at ioc.ee
Tue Jan 2 10:08:06 EST 2001


Hi,

In python 1.5.2, I have

>>> re.match(r'(?ms).*?}\s*\Z(?P<rest>.*)','{}\012}\012').groupdict()
{'rest': ''}

but in Python 2.0 the same match gives

>>> re.match(r'(?ms).*?}\s*\Z(?P<rest>.*)','{}\012}\012').groupdict()
{'rest': '\012}\012'}

which is surprising because according to docs:

\Z  Matches only at the end of the string.

It seems that the `{}' part is somehow responsible to this behaviour
because

>>> re.match(r'(?ms).*?}\s*\Z(?P<rest>.*)','aa\012}\012').groupdict()
{'rest': ''}

is expected result and is obtained with Python 2.0.

In Python docs and its release notes I found nothing that could explain
this behaviour. 

So, is this a bug or an undocumented feature? If later, could some
one, please, explain the basics of this feature? If former, any hints how
to go around this bug without updating Python from CVS after it is fixed?

Thanks,
	Pearu




More information about the Python-list mailing list