in reply to Re: regex for negating a sequence
in thread regex for negating a sequence

Your regexp can be simplified to the following:

/\x26\x67(?:(?!\x26\x67).){7}./s

If you'd rather have simplicity at the cost of an extra check, use the following:

/\x26\x67(?:(?!\x26\x67).){8}/s

/(?:(?!$re).){8}/
is the equivalent of
/[^$chars]{8}/
but it (negatively) matches entire regexps instead of a choice of characters.

Replies are listed 'Best First'.
Re^3: regex for negating a sequence
by ysth (Canon) on Oct 03, 2006 at 20:25 UTC
    Another alternative:
    /\x26\x67(?!.{0,6}\x26\x67).{8}/s
    I've interpreted "does not appear" differently than you when the eighth char is the \x26 of a \x26\x67 sequence.
Re^3: regex for negating a sequence
by davidrw (Prior) on Oct 03, 2006 at 20:40 UTC
    nice. My first attempt was trying to do it like that, but i started with something like:
    /\x26\x67(.(?!\x26\x67)){7}./s
    which doesn't work for the case of consectutive sequences.. i just didn't think of putting the look-ahead behind the dot :)