时间:2021-07-01 10:21:17 帮助过:22人阅读
$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);