in reply to Re: Negative Lookahead Assertion Problem
in thread Negative Lookahead Assertion Problem

You missed the literal ( after the \s*. Together, \s*( does specify a meaningful assertion. In your tests, all your sample data is supposed to not match by my understanding of the OP. Only something such as "Foo::Bar is my favorite module" should match.
  • Comment on Re^2: Negative Lookahead Assertion Problem

Replies are listed 'Best First'.
Re^3: Negative Lookahead Assertion Problem
by monarch (Priest) on Jul 19, 2005 at 11:39 UTC
    I'm confused by your post. Breaking down qr/Foo::Bar(?!\s+\()/ we get:
    Foo::Bar # literal 'Foo::Bar' (?! # start of negative look-ahead \s+ # one or more white space chars \( # literal opening bracket ) # end of negative look-ahead
    so to answer your reply, I believe I provided the literal ( after the \s*.

    To answer your other statement, that something such as "Foo::Bar is my favourite module" should match, I agree - that is how I read the initial requirement from the thread. In which case my answer of using \s+ kept within the spirit of the original statements made by the thread author. However I wanted to keep my example in line with the example that the author had tried, hence the use of the literal (. Hope this clears up my answer.

      My point was that only something like "Foo::Bar is my favorite module" should match, not "Foo::Bar()" and " Foo::Bar()" (which changing * to + make match).

      As to "missing )", I meant (but put it poorly) in your statement:

      Surely trying to match \s* is futile in a negative-lookup? Because \s* can match nothing it will always succeed, thereby never matching??
      The assertion wasn't \s*, it was \s*\(, a horse of a completely different color.