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.
正则表达式是:[%{1,2}|\/\/]
[%{1,2}|\/\/]
这匹配%,%%并且//
%
%%
//
仅供参考:这是从 flycheck 生成的警告。
警告意味着您的角色类中有重复项。当你把东西放在方括号之间时,它的意思是“其中之一”:[abc]表示 a、b 或 c 中的任何一个。[a|b]表示或中a的任何一个|b
[abc]
[a|b]
a
|
b
因此,当您这样做时[\/\/],您的意思是“要么/,要么/”,这显然是重复的。出于同样的原因,[%{1,2}]意思是“%或或{或1或,或2或}”,这显然不是你想要的。
[\/\/]
/
[%{1,2}]
{
1
,
2
}
组选择器是括号,而不是方括号,所以请改用这个正则表达式:
(%{1,2}|\/\/)