在Vim中对某些字符进行分组,需要使用\(\)序列。其他特殊情况也是如此:\ {\}。
是否可以将正则表达式更改为perl?如何切换?
相反
\\(
我会
(
???
答案 0 :(得分:11)
您可以更改默认所需的“魔术等级”
:se nomagic
:se magic
请参阅:he magic
我建议使用相应的转义符来避免破坏其他映射。
/\v(\d+)
将匹配您期望的Perl Regex连续数字
来自 pattern.txt帮助:
Examples:
after: \v \m \M \V matches ~
'magic' 'nomagic'
$ $ $ \$ matches end-of-line
. . \. \. matches any character
* * \* \* any number of the previous atom
() \(\) \(\) \(\) grouping into an atom
| \| \| \| separating alternatives
\a \a \a \a alphabetic character
\\ \\ \\ \\ literal backslash
\. \. . . literal dot
\{ { { { literal '{'
a a a a literal 'a'
{only Vim supports \m, \M, \v and \V}
It is recommended to always keep the 'magic' option at the default setting,
which is 'magic'. This avoids portability problems. To make a pattern immune
to the 'magic' option being set or not, put "\m" or "\M" at the start of the
pattern.