in reply to Re: Using negative lookahead
in thread Using negative lookahead

"Unfortunately regexes don't support backreferences in character classes - like [^\g1] - to forbid the delimiter inside the string. (at least I couldn't find it.)"

I wouldn't think that would work in the general case, where \g1 refers to more than one character, would it?

Replies are listed 'Best First'.
Re^3: Using negative lookahead
by LanX (Saint) on Oct 20, 2017 at 14:01 UTC
    depends what you mean with the general case.

    Do you mean ...

    • ... [^\g1] with \g1 more than one letter?
    This is hypothetical, since even one letter doesn't work.
    • ... ( (?! \g1) .)*
    This Would disallow a multibyte sequence if the match holds a word.

    I.e. like the word "not" to be forbidden to follow

    • ... ( (?! \g1) (?! \g2) .)*
    Here chaining look-aheads work like AND conditions.

    For single bytes, this would be equivalent of [^\g1\g2] (if it was possible)

    you might be interested this excellent tutorial

    Using Look-ahead and Look-behind

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!