1.2 KiB
1.2 KiB
alias
alias | ||||||
---|---|---|---|---|---|---|
|
up:: vim regex title:: "before and after matches" #s/informatique
Allows to match pattern after (lookahead) or before (lookbehind) the current pattern.
Quick reference
\zs
starts the selection (everything before is searched for but not matched)\ze
stop the selection (everything after is searched for but not matched)
positive | negative | |
---|---|---|
lookahead | @= |
@! |
lookbehind | @<= |
@<! |
Exemples
[!example] president (not (Macron|Hollande)) To match President if it is not
President Macron
orPresident Hollande
. Note that the match will select onlyPresident
(else the regex is obvious).President\(Macron\|Hollande\)\@!
Or, with verymagic mode\vPresident(Macron|Hollande)@!
[!example] python attributes, but not of self Match any python attribute (a word after a dot), except attributes of
self
(attributes of an object from the object itself)\(self\)\@<!\.\zs\w\+
or, with verymagic mode\v(self)@<!.\zs\<+