- ()
- +
meaning | perl | vim | remark |
---|---|---|---|
Matches the preceding atom with zero width | (?=pattern) | @= | |
Matches with zero width if the preceding atom does NOT match at the current position. | (?!pattern) | @! | |
Matches with zero width if the preceding atom matches just before what follows. | (?<=pattern) | @<= | Vim allows non-fixed-width patterns |
Matches with zero width if the preceding atom does NOT match just before what follows. Thus this matches if there is no position in the current or previous line where the atom matches such that it ends just before what follows. | (?<!pattern) | @<! | Vim allows non-fixed-width patterns. |
Matches the preceding atom like matching a whole pattern | (?>pattern) | @> |
Vim has \zs and \ze to start and end matching, so you usually don't have to deal with normal regex lookaround.
e.g: :%s/^rs\d\{1,12}\zs-/\t/g
character name | find | substitude |
---|---|---|
new line | \n | \r |
Instead of .*
use .\{-}
.
%s/style=".\{-}"//g
Also, see :help non-greedy
See: https://stackoverflow.com/questions/1305853/how-can-i-make-my-match-non-greedy-in-vim