Ezio Melotti <[email protected]> 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 <[email protected]>
<http://bugs.python.org/issue2636>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com