Question

So another question led me to wondering if there is a way to negate a regex backreference without using lookarounds? The original post is here, but the approved answer is using lookarounds. In places those are not supported, is there a clean way to handle negative backreferences? I have found on a regex site [^\x] where x is the backref. number, does not work as intended.

For example: Find a number followed directly by any other number (but dynamic in the number). It would make sense to have (\d)[^\1], but inside a character class, everything is taken literally.

Was it helpful?

Solution

is a way to negate a regex backreference without using lookarounds?

No.

In theory, how are the lookarounds being generated by the regex engine?

Lookarounds are not "generated" with other simpler regex constructs, they are a distinct feature of their own.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top