any-rule icon indicating copy to clipboard operation
any-rule copied to clipboard

我有更好的正则: 身份证号(1代,15位数字)

Open strangePix opened this issue 2 years ago • 1 comments

月份判断可以优化,月份不会是00月 原:/^[1-9]\d{7}(?:0\d|10|11|12)(?:0[1-9]|[1-2][\d]|30|31)\d{3}$/ 现:/^[1-9]\d{7}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2][\d]|30|31)\d{3}$/

可以更细,把每个月的天数做个判断: /^[1-9]\d{7}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|30|31)|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))\d{3}$/

strangePix avatar Feb 07 '23 03:02 strangePix

感谢, 我测试一下

any86 avatar Apr 14 '23 15:04 any86