Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
strangePix opened this issue Feb 7, 2023 · 1 comment
Open

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

strangePix opened this issue Feb 7, 2023 · 1 comment
Labels
🍕待同步到代码 稍后同步到代码中

Comments

@strangePix
Copy link

月份判断可以优化,月份不会是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}$/

@any86
Copy link
Owner

any86 commented Apr 14, 2023

感谢, 我测试一下

@any86 any86 added the 🍕待同步到代码 稍后同步到代码中 label Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍕待同步到代码 稍后同步到代码中
Projects
None yet
Development

No branches or pull requests

2 participants