java号段_Java匹配国内手机号码段

目前(2016-12-7)三大运营商最新号段如下

移动号段:

134 135 136 137 138 139 147 150 151 152 157 158 159 178 182 183 184 187 188

联通号段:

130 131 132 145 155 156 171 175 176 185 186

电信号段:

133 149 153 173 177 180 181 189

虚拟运营商:

170

通过java语言写一个手机号码段校验工具类PhoneNumUtil如下:

import java.text.ParseException;

import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;

/**

* 手机号码工具类

*/

public class PhoneNumUtil {

public static void main(String[] args) throws ParseException {

System.out.println(checkPhone("13801246482"));

System.out.println(checkPhone("17001246482"));

System.out.println(checkPhone("1501246482"));

}

/**

* 中国手机号码校验

*

* @param phone

* @return

*/

public static boolean checkPhone(String phone) {

if (StringUtils.isNotBlank(phone)) {

Pattern regexp = Pattern.compile("^(13[0-9]|14[579]|15[012356789]|17[135678]|18[0-9])[0-9]{8}$");

if (regexp.matcher(phone).matches()) {

return true;

}

}

return false;

}

/**

* 中国移动手机号码校验

*

* @param phone

* @return

*/

public static boolean checkChinaMobile(String phone) {

if (StringUtils.isNotBlank(phone)) {

Pattern regexp = Pattern.compile("^(13[456789]|14[7]|15[012789]|17[8]|18[23478])[0-9]{8}$");

if (regexp.matcher(phone).matches()) {

return true;

}

}

return false;

}

/**

* 中国联通手机号码校验

*

* @param phone

* @return

*/

public static boolean checkChinaUnicom(String phone) {

if (StringUtils.isNotBlank(phone)) {

Pattern regexp = Pattern.compile("^(13[012]|14[5]|15[56]|17[156]|18[56])[0-9]{8}$");

if (regexp.matcher(phone).matches()) {

return true;

}

}

return false;

}

/**

* 中国电信手机号码校验

*

* @param phone

* @return

*/

public static boolean checkChinaTelecom(String phone) {

if (StringUtils.isNotBlank(phone)) {

Pattern regexp = Pattern.compile("^(13[3]|14[9]|15[3]|17[37]|18[019])[0-9]{8}$");

if (regexp.matcher(phone).matches()) {

return true;

}

}

return false;

}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值