Message79853
Well, in this example the group (ar) is unmatched, so sre throws the
error, and because of the alternation, the workaround you mentioned
doesn't seem to directly apply.
A better example is probably
re.sub("foo(?:b(ar)|foo)","\\1","foofoo")
because this can't be simply repaired by refactoring the regex.
The correct behaviour, as I have observed in other regex
implementations, is to replace the group by the empty string; for
example, in Javascript:
>>> 'foobar'.replace(/foo(?:b(ar)|baz)/,'$1')
"ar"
>>> 'foobaz'.replace(/foo(?:b(ar)|baz)/,'$1')
"" |
|
Date |
User |
Action |
Args |
2009-01-14 14:34:03 | nneonneo | set | recipients:
+ nneonneo, effbot, mchaput, timehorse, BMintern, gerardjp |
2009-01-14 14:34:03 | nneonneo | set | messageid: <1231943643.23.0.579673348714.issue1519638@psf.upfronthosting.co.za> |
2009-01-14 14:34:02 | nneonneo | link | issue1519638 messages |
2009-01-14 14:34:00 | nneonneo | create | |
|