有经验的编程大师?救救小白,一个很简答的需求。判断身份证号和生日是否相同,应该要用的正则表达式?

小程序 文章 2020-08-10 14:41 577 0 全屏看文

AI助手支持GPT4.0

有经验的编程大师?救救小白,一个很简答的需求。判断身份证号和生日是否相同,应该要用的正则表达式?Experienced programming master? Save Xiaobai, a very simple need. Which regular expression should be used to determine whether the ID number and birthday are the same?

有经验的编程大师?救救小白,一个很简答的需求。判断身份证号和生日是否相同,应该要用的正则表达式?

1.网上这种很多,但没有找到合适的。现在身份证号有15位的,18位的。

2.需求:需要验证身份证号码格式对不对?身份证号码和选择的生日对的上吗?



1. There are a lot of them on the Internet, but there is no suitable one. Now the ID number has 15 digits and 18 digits. 2. Requirement: need to verify the ID card number format, right? Is the ID card number and the chosen birthday right? 

回答:

拾忆:

这种问题直接百度不更多现成答案吗?

15位身份证号码第7-12位表示出生年月日,比如670401代表196741日/(?<=d{6})(d{2})(d{2})(d{2})(?=d{3})/18位身份证号码第7-14位表示出生年月日,比如19670401代表196741日/(?<=d{6})(d{4})(d{2})(d{2})(?=d{3})/


卢霄霄:

有身份证号了,还需要手动选生日吗

Zero:

先判断身份证是18位的还是15位的,然后提取身份证中的出生日期,提取出来的格式调整一下(例如:1998-08-08)。然后两者对比就行了

Subsist:

???、 直接提取年月日,对比身份证里面是否存在就行了白,正则什么东西??

。:身份证的位数可能不同啊?

-EOF-

AI助手支持GPT4.0