Home > Web Front-end > JS Tutorial > body text

Android phone number verification rules

php中世界最好的语言
Release: 2018-03-29 10:36:23
Original
1907 people have browsed it

这次给大家带来Android手机号验证正则,Android手机号验证正则的注意事项有哪些,下面就是实战案例,一起来看一下。

下面给大家分享2018手机号正则表达式验证方法,具体内容如下所示:

/** 
* 判断字符串是否符合手机号码格式 
* 移动号段: 134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188 
* 联通号段: 130,131,132,145,155,156,170,171,175,176,185,186 
* 电信号段: 133,149,153,170,173,177,180,181,189 
* @param str 
* @return 待检测的字符串 
*/
Copy after login
public static boolean isMobileNO(String mobileNums) { 
  /** 
   * 判断字符串是否符合手机号码格式 
   * 移动号段: 134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188 
   * 联通号段: 130,131,132,145,155,156,170,171,175,176,185,186 
   * 电信号段: 133,149,153,170,173,177,180,181,189 
   * @param str 
   * @return 待检测的字符串 
   */ 
  String telRegex = "^((13[0-9])|(14[5,7,9])|(15[^4])|(18[0-9])|(17[0,1,3,5,6,7,8]))\\d{8}$";// "[1]"代表第1位为数字1,"[358]"代表第二位可以为3、5、8中的一个,"\\d{9}"代表后面是可以是0~9的数字,有9位。 
  if (TextUtils.isEmpty(mobileNums)) 
    return false; 
  else 
    return mobileNums.matches(telRegex); 
}
Copy after login

”^((13[0-9])|(14[5,7,9])|(15[^4])|(18[0-9])|(17[0,1,3,5,6,7,8]))\d{8}$”这句话其实很简单:

①130-139这十个前三位已经全部开通,后面8位每一位都是0-9之间的任意数;

②14开头的目前只有145、147、149三位,后面8位每一位都是0-9之间的任意数;

③15开头的除了154以外第三位可以随意取,后面8位每一位都是0-9之间的任意数;

④180-189这十个前三位已经全部开通,后面8位每一位都是0-9之间的任意数;

⑤17开头的目前有170、171、173、175、176、177、178这七位,后面8位每一位都是0-9之间的任意数;

相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!

推荐阅读:

验证用户设置的密码强度正则表达式

vue2.0 axios跨域和渲染有哪些需要注意的

The above is the detailed content of Android phone number verification rules. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!