regexp weirdness (bug?)

André Malo auch-ich-m at g-kein-spam.com
Tue Apr 5 12:16:51 EDT 2005


* Sergey Schetinin wrote:

> Here's the session log:
> 
>>>> _re_pair="(?(plus).|-)"
>>>> _re1=("(?P<plus>\+)"+_re_pair)
>>>> _re2=("((?P<plus>\+))"+_re_pair)
>>>> _re3=("(?:(?P<plus>\+))"+_re_pair)
>>>> _re4="(%s)"%_re3
>>>> import re
>>>> print [re.match(_re, "+a") and 'match' for _re in [_re1, _re2,
> _re3, _re4]]
> ['match', None, 'match', None]
> 
> this is not the supposed behaivour. all theese patterns should match,
> right?

No, I suppose they shouldn't compile.
_re_pair should be (?P=plus).

nd




More information about the Python-list mailing list