regex, lookbehind error
-
I tried (?<=\s+) for searching 2 or more empty (allowing tab or spacebar inserted) line but this gives me an error.
The error message is ‘Find : invalid regular expression’.I tested lookbehind and \s+ separately and both work fine. I want to know what is wrong when those two expressions are combined together.
Actually, even (?<=\s) work fine too, but when I add + or * to the right side of \s to allow multiple whitespaces, the error occurs. Someone help me please.
-
Lookbehinds must be of a fixed length. \s+ is not fixed width.
https://npp-user-manual.org/docs/searching/#assertions
edit: the manual also suggests a workaround using
\K
, so instead of(?<=\s+)REALTEXT
, use\s+\KREALTEXT
-
Additionally to what @PeterJones said, I want to mention that this is a restriction of the boost regular expression engine that Notepad++ uses under the hood. There are a few regular expression engines that don’t have this restriction (see section Important Notes About Lookbehind >> at this site <<), but in Notepad++ we have to live with it.
-
@PeterJones Thank you so much, I understood what I need.
-
@dinkumoil Thank you, actually I’m studying regex with 'Mastering Regex by Jeffrey Friedl and maybe I didn’t consider the differences on those engines.