sre negated lookaheads/behinds

Andrew Kuchling akuchlin at mems-exchange.org
Wed Oct 18 18:58:38 EDT 2000


Robin Becker <robin at jessikat.fsnet.co.uk> writes:
> Clearly my a( is not preceded by self. in either case. However, in the
> first case as there is not enough room for the positive look behind I
> think it is wrongly failing to match. Is this correct?

I think you've found a bug.  (First bug found in 2.0?) The ASSERT_NOT
opcode contains this bit of code:
     if (state->ptr < state->beginning)
                 return 0;

I think this is wrong; if the pattern is too long to match, then
clearly the negative lookbehind succeeds, so it should simply continue
matching the rest of the pattern.  Patch #101972 on SourceForge is a
proposed fix; /F has to approve it first.
 
> I know the documentation mentions that the (?< ... ) patterns must be
> fixed length, but nowhere does it say that negated patterns must be
> fixed length.

Er, yes, the docs do in fact say that.  But that isn't the problem
biting you.

--amk



More information about the Python-list mailing list