正则严格验证身份证信息,严格验证身份证信息_PHP教程

WBOY
发布: 2016-07-13 10:09:43
原创
921 人浏览过

正则严格验证身份证信息,严格验证身份证信息

<span>$a</span> = '130424770827005'<span>;

</span><span>$reg18</span> = '/[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)/'<span>;
</span><span>$reg15</span> = '/[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}/'<span>;
问题是对年份进行了判断从1800到2019<br />等4年就需要修改。<br />其实还可以更严格些。
</span><span>preg_match</span>(<span>$reg15</span>,<span>$a</span>,<span>$mm</span><span>);
</span><span>var_dump</span>(<span>$mm</span><span>);


输出结果
</span><span>array</span> (size=6<span>)
  </span>0 => <span>string</span> '130424770827005' (length=15<span>)
  </span>1 => <span>string</span> '08' (length=2<span>)
  </span>2 => <span>string</span> '08' (length=2<span>)
  </span>3 => <span>string</span> '' (length=0<span>)
  </span>4 => <span>string</span> '27' (length=2<span>)
  </span>5 => <span>string</span> '27' (length=2)
登录后复制

 

www.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}...
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板