You'd want to use regex capture groups, as follows:
/v%(PATTERN.*
.*)@<!(PATTERN)%(.*
.*1)@!
This might look scary, but it's actually quite simple:
v
is used to enable "very magic" regex (avoids the usage of backslashes for most special characters)
PATTERN.*
.*
is PATTERN
, followed by anything, a newline, and anything again
(...)@<!
is the pattern for negative look-behind: it means that we don't want what's between the braces to exist. So in our case, all of step 2
shouldn't exist
(PATTERN)
This is our actual word, this should exist! We capture it with braces for future usage
.*
.*1
is anything, a newline, anything again, and our captured group (see step 4
)
%(...)@!
is a negative look-ahead, as before, we don't want what's between the braces to exist.
So basically, we want PATTERN
, which is:
- not preceded by a line containing
PATTERN
- not succeeded by a line containing
PATTERN
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…