Negative lookahead, Negative lookbehind

Advanced Renamer forum
#1 : 21/01-21 20:12
Posts: 2
Negative lookahead, Negative lookbehind, Are these regex functions supported?

21/01-21 20:12
#2 : 21/01-21 23:55
David Lee
David Lee
Posts: 612
Reply to #1:
Lookahead is supported by PCRE but not lookbehind.

However there is a workaround - the meta-character "\K" is an indication to exclude the characters already matched from the final match.

So the regex "abc\Kdef" will match "def" but only if it is immediately preceded by "abc"

Likewise for the negative version: "(^|[^(abc)]\K)def"

21/01-21 23:55 - edited 22/01-21 10:43