in reply to Re^3: how to find what's not there with a regex?
in thread how to find what's not there with a regex?

hmmm.... (?! xyz ) { what-bang? :) }

New one on me, but that's an excellent idea.

Stop when you see xyz...

Perl++ never ceases to amaze me.
  • Comment on Re^4: how to find what's not there with a regex?

Replies are listed 'Best First'.
Re^5: how to find what's not there with a regex?
by ikegami (Patriarch) on Aug 24, 2005 at 15:15 UTC

    It's the zero-width negative lookahead operator. In English, it means "not immediately followed by", and it doesn't move pos, so the next item in the regexp will start matching as if the (?!...) wasn't there.

    It's almost always used as
    (?: (?! ...regexp... ) .)*
    or
    (?: (?! ...regexp... ) .)+
    Anything else is should be very carefully inspected.