我想要一个特定的值,该值只能是数字并且:
长度应为 11。
第一个数字应该是 0。
第二位数字应该是 1。
第三位数字应该是 0, 1, 2, 5。
然后匹配从第四位到末尾的任何数字。
如果第三位数字是1,则最后两位数字(第10、11)应该相同。
如果第三位是2,则第八位、第九位应该相同。
输入字符串和预期结果。
01012345678 -----> allowed.
0101234a5678 -----> not allowed., letter exists.
01112345688 -----> allowed, 10th, 11st are the same
01112345677 -----> allowed, 10th, 11st are the same
01112345666 -----> allowed, 10th, 11st are the same
01112345689 -----> not allowed..10th, 11st different
01112345-678 -----> not allowed..hyphen exists.
01298765532 -----> allowed..8th, 9th are the same.
01298765732 -----> not allowed, 8th, 9th different.
01298765mm432 -----> not allowed, letter exists. …Run Code Online (Sandbox Code Playgroud)