无法理解Benoit在此帖子中的回答中\@<=
和\@=
的含义,有人可以帮忙解释一下吗?
\@= Matches the preceding atom with zero width. {not in Vi}
Like "(?=pattern)" in Perl.
Example matches
foo\(bar\)\@= "foo" in "foobar"
foo\(bar\)\@=foo nothing
*/zero-width*
When using "\@=" (or "^", "$", "\<", "\>") no characters are included
in the match. These items are only used to check if a match can be
made. This can be tricky, because a match with following items will
be done in the same position. The last example above will not match
"foobarfoo", because it tries match "foo" in the same position where
"bar" matched.
Note that using "\&" works the same as using "\@=": "foo\&.." is the
same as "\(foo\)\@=..". But using "\&" is easier, you don't need the
braces.
\@<= Matches with zero width if the preceding atom matches just before what
follows. |/zero-width| {not in Vi}
Like '(?<=pattern)" in Perl, but Vim allows non-fixed-width patterns.
Example matches
\(an\_s\+\)\@<=file "file" after "an" and white space or an
end-of-line
For speed it's often much better to avoid this multi. Try using "\zs"
instead |/\zs|. To match the same as the above example:
an\_s\+\zsfile
"\@<=" and "\@<!" check for matches just before what follows.
Theoretically these matches could start anywhere before this position.
But to limit the time needed, only the line where what follows matches
is searched, and one line before that (if there is one). This should
be sufficient to match most things and not be too slow.
The part of the pattern after "\@<=" and "\@<!" are checked for a
match first, thus things like "\1" don't work to reference \(\) inside
the preceding atom. It does work the other way around:
Example matches
\1\@<=,\([a-z]\+\) ",abc" in "abc,abc"
:h /\@='
和:h /\@<=
。帮助页面提供了非常清晰的解释。 - FDinoffE149: 对于 /\@='
,很抱歉没有帮助,我正在使用 Mac OS X 终端上的 Vim v7.3。 - George:h /\@=
和:h /\@<=
。 - FDinoff