vim search numbers containing specific number of digits
There are different regular expression dialects; some (e.g. Perl's) do not require backslashes in the quantification modifier (\d{2}
), some (e.g. sed) require two (\d\{2\}
), and in Vim, only the opening curly needs it (\d\{2}
). That's the sad state of incompatible regular expression dialects.
Also note that for matching exact numbers, you have to anchor the match so that \d\{2}
won't match to digits (12
) in 123
. This can be done with negative look-behind and look-ahead:
\d\@<!\d\{2}\d\@!
Try the following:
\d\{2}
and you should use \
not /
You can find out more about the regular exression of vim on this site or in vim
with :help regular
.
Escaping brackets works: \d\{2\}