Home > Backend Development > PHP Tutorial > 手机号码正则表达式

手机号码正则表达式

WBOY
Release: 2016-06-23 13:52:10
Original
982 people have browsed it

 /**
    * 匹配手机号码
    * 1 3
    *       0123456789
    *   4
    *       57
    *   5
    *       0123456789
    *   7
    *   8
    **/
    $number = '13956789032';

    $pattern = '/1(3\d|4\[57]|5\d|7[01]|8\d)\d{8}/';

    if(preg_match($pattern ,$number ,$arr)){
    
        var_dump($arr);
    


回复讨论(解决方案)

so  ,你遇到什么问题了?

手机号11位数字,简单点的就是\d{11}
如果要更加严谨,那就判断手机号的前缀。

但你这个正则已经很好了,可以判断到 15X  13X  18X   其它的没有了什么好的建议了。

有没有更加完整的验证,说思路就行

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template