in reply to Re: RegEx - match pattern not followed by literal
in thread RegEx - match pattern not followed by literal

I think your negative look-ahead needs to be something like (?!.*,v$) because you don't know where the user-supplied regex is going to leave off matching. I agree with Fletch, however, as the optimisation game is probably not worth the candle.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^3: RegEx - match pattern not followed by literal
by Melly (Chaplain) on Oct 12, 2006 at 15:42 UTC

    I don't think a negative look ahead will work - .*(?!,v) will still match foo,v since the .* can just suck up the ,v

    Tom Melly, tom@tomandlu.co.uk
      Yes, perhaps that needs to be non-greedy like (?!.*?,v$) but note that the .*? is inside the assertion.

      Cheers,

      JohnGG