开发者

strange behavior in vim with negative look-behind

So, I am doing this search in vim:

/\(\(unum\)\|\(player\)=\)\@<!\"1\"

and as expected it does not match lines that have:

player="1" 

but matches lines that have:

unum="1" 

what am i doing wrong? isn't the atom to be negated all of this: \(\(unum\)\|\(player\)=\)

naturally just doing: /\(\(unum\)\|\(player\)=\)开发者_运维问答 matches unum= or player=.


Your pattern is

\(
    \(unum\)\|
    \(player\)=
\)\@<!"1"

which is equivalent to

\(
    \(unum\)\|
    \(player=\)
\)\@<!"1"

And it must be

\(
    \(unum\|player\)=
\)\@<!"1"

Just remove one closing and one opening parenthesis.

And, writing \" is strange: in situations where you have to escape " you also need to escape slash.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜