[issue2636] Adding a new regex module (compatible with re)

Ezio Melotti report at bugs.python.org
Thu Sep 1 19:13:07 CEST 2011


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

I tried to run a test suite of 3kloc (not just about regex, but regex were used in several places) and I had only one failure:
>>> s = u'void foo ( type arg1 [, type arg2 ] )'
>>> re.sub('(?<=[][()]) |(?!,) (?!\[,)(?=[][(),])', '', s)
u'void foo(type arg1 [, type arg2])'
>>> regex.sub('(?<=[][()]) |(?!,) (?!\[,)(?=[][(),])', '', s)
u'void foo ( type arg1 [, type arg2 ] )'

Note than when the two patterns are used independently they both yield the same result on re and regex, but once they are combined the result is different:
>>> re.sub('(?<=[][()]) ', '', s)
u'void foo (type arg1 [, type arg2 ])'
>>> regex.sub('(?<=[][()]) ', '', s)
u'void foo (type arg1 [, type arg2 ])'

>>> re.sub('(?!,) (?!\[,)(?=[][(),])', '', s)
u'void foo( type arg1 [, type arg2])'
>>> regex.sub('(?!,) (?!\[,)(?=[][(),])', '', s)
u'void foo( type arg1 [, type arg2])'

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2636>
_______________________________________


More information about the Python-bugs-list mailing list