Regex
1. Regular Expressions in Vim
1.1. Lookahead and Lookbehind
Directly some examples.
See :help /\@=
, :help /\@!
, :help /\@<=
, and :help /\@<!
for detail.
1.1.1. Positive lookahead with \@=
and negative lookahead with \@!
1 | quick fox quick dog quick fox |
Find quick
if followed by dog
with /quick\( dog\)\@=
.
Find quick
if not followed by dog
with /quick\( dog\)\@!
.
1.1.2. Positive Lookbehind with \@<=
and negative Lookbehind with \@<!
Find fox
preceded by quick
with \(quick \)\@<=fox
.
Find fox
not preceded by quick
with \(quick \)\@<!fox
.