Message109382
| Author |
acooke |
| Recipients |
acooke |
| Date |
2010年07月06日.10:23:32 |
| SpamBayes Score |
0.0037326002 |
| Marked as misclassified |
No |
| Message-id |
<1278411814.72.0.368411829683.issue9179@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
from re import compile
# these work as expected
assert compile('(a)b(?<=b)(c)').match('abc')
assert not compile('(a)b(?<=c)(c)').match('abc')
assert compile('(a)b(?=c)(c)').match('abc')
assert not compile('(a)b(?=b)(c)').match('abc')
# but when you add groups, you get bugs
assert not compile('(?:(a)|(x))b(?<=(?(2)x|c))c').match('abc') # matches!
assert not compile('(?:(a)|(x))b(?<=(?(2)b|x))c').match('abc')
assert compile('(?:(a)|(x))b(?<=(?(2)x|b))c').match('abc') # fails!
assert not compile('(?:(a)|(x))b(?<=(?(1)c|x))c').match('abc') # matches!
assert compile('(?:(a)|(x))b(?<=(?(1)b|x))c').match('abc') # fails!
# but lookahead works as expected
assert compile('(?:(a)|(x))b(?=(?(2)x|c))c').match('abc')
assert not compile('(?:(a)|(x))b(?=(?(2)c|x))c').match('abc')
assert compile('(?:(a)|(x))b(?=(?(2)x|c))c').match('abc')
assert not compile('(?:(a)|(x))b(?=(?(1)b|x))c').match('abc')
assert compile('(?:(a)|(x))b(?=(?(1)c|x))c').match('abc')
# these are similar but, in my opinion, shouldn't even compile
# (group used before defined)
assert not compile('(a)b(?<=(?(2)x|c))(c)').match('abc') # matches!
assert not compile('(a)b(?<=(?(2)b|x))(c)').match('abc')
assert not compile('(a)b(?<=(?(1)c|x))(c)').match('abc') # matches!
assert compile('(a)b(?<=(?(1)b|x))(c)').match('abc') # fails!
assert compile('(a)b(?=(?(2)x|c))(c)').match('abc')
assert not compile('(a)b(?=(?(2)b|x))(c)').match('abc')
assert compile('(a)b(?=(?(1)c|x))(c)').match('abc')
# this is the error we should see above
try:
compile('(a)\2円(b)')
assert False, 'expected error'
except:
pass |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2010年07月06日 10:23:35 | acooke | set | recipients:
+ acooke |
| 2010年07月06日 10:23:34 | acooke | set | messageid: <1278411814.72.0.368411829683.issue9179@psf.upfronthosting.co.za> |
| 2010年07月06日 10:23:32 | acooke | link | issue9179 messages |
| 2010年07月06日 10:23:32 | acooke | create |
|