我有这个正则表达式我建立和正则表达式伙伴测试。什么是“嵌套量化器”,为什么它会导致我的正则表达式失败?
"_ [ 0-9]{10}+ {1}+[ 0-9]{10}+ {2}+[ 0-9]{6}+ {2}[ 0-9]{2}"
当我在.net C#中使用此
我收到异常
"parsing \"_ [ 0-9]{10}+ +[ 0-9]{10}+ +[ 0-9]{6}+ [ 0-9]{2}\" - Nested quantifier +."
这个错误是什么意思?显然.net不喜欢这个表情。
这里是正则表达式的好友,这样你们可以理解我的意图与正则表达式...
_ [ 0-9]{10}+ {1}+[ 0-9]{10}+ {2}+[ 0-9]{6}+ {2}[ 0-9]{2}
Match the characters "_ " literally «_ »
Match a single character present in the list below «[ 0-9]{10}+»
Exactly 10 times «{10}+»
The character " " « »
A character in the range between "0" and "9" «0-9»
Match the character " " literally « {1}+»
Exactly 1 times «{1}+»
Match a single character present in the list below «[ 0-9]{10}+»
Exactly 10 times «{10}+»
The character " " « »
A character in the range between "0" and "9" «0-9»
Match the character " " literally « {2}+»
Exactly 2 times «{2}+»
Match a single character present in the list below «[ 0-9]{6}+»
Exactly 6 times «{6}+»
The character " " « »
A character in the range between "0" and "9" «0-9»
Match the character " " literally « {2}»
Exactly 2 times «{2}»
Match a single character present in the list below «[ 0-9]{2}»
Exactly 2 times «{2}»
The character " " « »
A character in the range between "0" and "9" «0-9»
总之...
什么是嵌套量词?
在某些正则表达式中,{min,max} +是占有量词,但.Net不支持它们。如果您使用的是正则表达式好友,您可以通过右键单击合成窗格并从下拉列表中选择“风味”来告诉它正在使用哪种正则表达式。 – Grokodile 2011-06-24 15:57:21