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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top