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

Heh - yeah, looks like the single-regex solution is just too darned ugly (and I'd feel guilty handing that on to be maintained).

I'll stick with my original two regex solution (but implement that bastard Fletch's suggestion to swap the regexes and check for ,v$ first)

I guess I was just suprised that the reverse, /$users_regex,v$/, was so easy, but handling NOT ,v$ is so tricky...

Tom Melly, tom@tomandlu.co.uk
  • Comment on Re^3: RegEx - match pattern not followed by literal

Replies are listed 'Best First'.
Re^4: RegEx - match pattern not followed by literal
by ikegami (Patriarch) on Oct 12, 2006 at 15:57 UTC

    Regexps can do 'followed by' and 'or' easily, but not 'and'.

    I just thought of another solution:

    /$users_regex .*\z (?<!,v) (?<!,v\n)/xs

    Or if you really meant /,v\z/:

    /$users_regex .*\z (?<!,v)/xs
      You guys are making this a little more complicated than it needs to be. I think that /(?!.*,v$)$users_regex/ will suffice. As has already been said, though, the OP's first solution is probably cleanest.