时间:2021-07-01 10:21:17 帮助过:34人阅读
$a = '130424770827005'; $reg18 = '/[1-9]\d{5}(((1[9|8])\d{2})|(20[0-1]\d))((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)/'; $reg15 = '/[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}/'; 问题是对年份进行了判断从1800到2019输出结果 array (size=6) 0 => string '130424770827005' (length=15) 1 => string '08' (length=2) 2 => string '08' (length=2) 3 => string '' (length=0) 4 => string '27' (length=2) 5 => string '27' (length=2)
等4年就需要修改。
其实还可以更严格些。 preg_match($reg15,$a,$mm); var_dump($mm);
http://www.bkjia.com/PHPjc/942281.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/942281.htmlTechArticle正则严格验证身份证信息,严格验证身份证信息 $a = '130424770827005' ; $reg18 = '/[1-9]\d{5}(((1[9|8])\d{2})|(20[0-1]\d))((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}...