Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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.
您的表达式有两点错误:1.第一个大括号需要转义,2.量词内不应该有空格。
/\d\{2,4}/
见:help /\{。
:help /\{
如果您打开very magic,例如通过以 开头的表达式\v,则不需要转义第一个大括号:
very magic
\v
/\v\d{2,4}/