RegularExression 会是什么?
NN-ARID-NNN?
//N = Number
我试过这个^[0-9/-0-9]+$
答案 0 :(得分:3)
你根本不匹配ARID
,而且角色类会以任何顺序匹配......你可能想要使用更像这样的东西:
^[0-9]{2}-ARID-[0-9]{3}$
[假设?
不在实际字符串中......]
如果您希望前两位数字在00
到13
的范围内,那么您可以将OR运算符与|
和一个组一起使用:
^(?:0[0-9]|1[0-3])-ARID-[0-9]{3}$
^^^ ^ ^
| OR |
| |
+---- Group ---+
故障:
^ Matches beginning of string
(?: Beginning of group
0[0-9] Matches 00 to 09 only
| OR
1[0-3] Matches 10 to 13 only
) End of group
-ARID- Matches -ARID- literally
[0-9]{3} Matches 3 digits
$ Matches end of line
如果有匹配00
- 09
或10
- 13
的选项,则该模式无法与空白匹配。如果数字不存在,那就无法匹配。