in reply to negative regex without !~

/(?:$RegexGoesHere(?!)|(?=))/

Ok, right. The previous construction was incorrect. I think using the experimental conditional test would work here since now the (?!) does not connect via backtracking to the (?=).

/(?((?:$RegexGoesHere))(?!)|(?=))/

Replies are listed 'Best First'.
Re^2: negative regex without !~
by ysth (Canon) on Jul 22, 2004 at 22:26 UTC
    Doesn't work. (?!) just makes it take the second alternative. People have proposed a FAIL HERE mechanism, but there isn't one now.

    The alternate way (much worse than hv's IMO) that you sometimes see is (IIRC) /^(.(?!$regex))*\z/s

Re^2: negative regex without !~
by hv (Prior) on Jul 22, 2004 at 22:12 UTC

    Update: oops

    Ooh yes, that's much cleaner than my attempt. (You don't need the '(?=)' in there, but it's probably clearer with than without.)

    Hugo