0

Why is the following regex

/\d{2, 4}/

which I expect to identify all between 2 and 4 digits in a text not working when I run it on the following text

1234567890

in vim.

4

1 回答 1

7

您的表达式有两点错误:1.第一个大括号需要转义,2.量词内不应该有空格。

/\d\{2,4}/

:help /\{

如果您打开very magic,例如通过以 开头的表达式\v,则不需要转义第一个大括号:

/\v\d{2,4}/
于 2013-04-18T21:09:09.183 回答