in reply to User regexps

How could a user specify a regexp meaning, "Any string that does not have the phrase 'foo' in it?"
Abigail gave an elegant one. I would expect this variation to be a little more efficient by virtue of only engaging lookahead upon encountering an f: /^(?:[^f]*f(?!oo))*[^f]*$/s;

The PerlMonk tr/// Advocate

Replies are listed 'Best First'.
Re: Re: User regexps
by ysth (Canon) on Jan 14, 2004 at 16:50 UTC
    //s there is useless, since it only affects .
      As useless as the pockets on my Cargo Cult pants from Old Navy®.

      Update: Your suggestion of /^.*(?!foo)/ is the Right Way To Do It, anyway.


      The PerlMonk tr/// Advocate