Reputation: 23
I try to build simple regular expression to remove some parts of bad (unwanted) code and needed use look behind feature.
It worked until i added \s+
to it to exclude spaces from mark.
Eliminating parts of expression i finally got to (?<=\s+)foo
which is still warned as invalid expression.
It may looks a little weird or unclear so expanding it:
(?<=foo\s+)bar
is warned as invalid expression, where (?<=foo)\s+bar
is working but it marks spaces before bar.
I am use it in notepad++.
Upvotes: 1
Views: 701
Reputation: 163287
From the comment by @Toto Notepad++ does not support variable length lookbehind. It uses the boost regex.
Notepad++ does support \K
to reset the starting point of the reported match.
\bfoo\s+\Kbar\b
Another way is to capture bar in a capturing group.
\bfoo\s+(bar)\b
Note that \s
also matches a newline, and perhaps you might also use \h+
to match 1+ horizontal whitespace characters.
Upvotes: 1