Vim Regular Expression¶
Basics¶
(under construction)
Greedy vs non-greedy¶
(under construction)
Lookahead and lookbehind assertions¶
abc\(def\)\@=: Match abc if it is followed by def (lookahead assertion)
abc\(def\)\@!: Match abc if it is NOT followed by def (negative lookahead assertion)
\(abc\)\@<=def: Match def if it is preceded by abc (lookbehind assertion)
\(abc\)\@<!def: Match def if it is NOT preceded by abc (negative lookbehind assertion)
Match start and end¶
\zs: The "match start." Everything before \zs is treated as lookbehind assertion.
\ze: The "match end." Everything after \ze is treated as lookahead assertion.
Example:
" This prints 'def'
let x = matchstr('abc def ghi', 'abc \zsdef\ze ghi')
echo x
" This prints empty string
let y = matchstr('def ghi', 'abc \zsdef\ze ghi')
echo y
Named groups¶
(under construction)
Non-capturing groups¶
(under construction)