in reply to negative lookbehind heartburn

Do you have to use lookbehinds? Sometimes negating the problem statement simplifies things a little
unless ($str =~ /odd.*?weird/){ print "hit!\n"; }
--perlplexer

Replies are listed 'Best First'.
Re: Re: negative lookbehind heartburn
by thelenm (Vicar) on May 17, 2002 at 22:38 UTC
    Unfortunately this will also match strings that don't contain the substring "weird". Without using lookbehind lookahead, this problem will probably require two tests (one to test for "weird" and one to test for "odd"), since we only want strings containing "weird" but not "odd" before "weird". That was an odd sentence, how weird. :-)
      Yep, you are right. Thanks for pointing that out.

      --perlplexer