in reply to Re: negative lookaheads doing my 'ead in
in thread negative lookaheads doing my 'ead in

right
I just re-read my original question and of course what I meant was why does it match?

When I run the above pattern it does match

  • Comment on Re: Re: negative lookaheads doing my 'ead in

Replies are listed 'Best First'.
Re: Re: Re: negative lookaheads doing my 'ead in
by BrowserUk (Patriarch) on Nov 08, 2002 at 11:42 UTC

    The reason it matches is because the immediate preceeding whitespace is optional \s*. Therefore the parser can choose to say that if there is no whitespace, then the next char after the second (\w+) is a space, which isn't '<=' so therefore is can match, so it does.

    Change that to be if (/^\s*(?!for all)(\w+)\s*:\s*(\w+)\s+(?!<=)/i) { and it no longer can match, so it doesn't (if you get my drift.

    I realise that may or may not help you.

    ++Jasper below. I couldn't find a way of doing that. The caveat is that if you wanted to match

    'cidr_enable: en_core_id == NOT(dsp_reset_n) AND <= stuff;'

    your out of luck.


    Nah! You're thinking of Simon Templar, originally played (on UKTV) by Roger Moore and later by Ian Ogilvy