正则拓展: 匹配大陆和港式身份证

前端之家收集整理的这篇文章主要介绍了正则拓展: 匹配大陆和港式身份证前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

直入主题

产品有香港的小伙伴入驻..身份证校验这块需要做一个前台校验,尝试了许久…就放出来了

两种写法:

  1. (\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X|x)|[A-Za-z]{1}\d{6}[(\d)]{3}
  2. ([A-Za-z](\d{6})\(\d\))|(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X|x)

效果

原文链接:https://www.f2er.com/regex/359297.html

猜你在找的正则表达式相关文章