我最近遇到了Vim regex builtins中的分支说明符。 Vim的帮助部分 \&
包含这个:
A branch is one or more concats, separated by "\&". It matches the last
concat, but only if all the preceding concats also match at the same
position. Examples:
"foobeep\&..." matches "foo" in "foobeep".
".*Peter\&.*Bob" matches in a line containing both "Peter" and "Bob"
目前尚不清楚它是如何使用的以及它的用途。对它的作用以及如何使用它的一个很好的解释将是伟大的。
要明确这一点 不 该 &
(替换为整个匹配)用于替换,这就是 \&
用在一个模式中。
用法示例:
/\c\v([^aeiou]&\a){4}
用于搜索4个连续辅音(取自vim提示)。