/**
* @Author guocongcong
* @Date 2018/2/28
* @Describe 手机号工具类
*/
public class PhoneUtils {
/*
1、移动号段有134,135,136,137, 138,139,147,150,151, 152,157,158,159,178,182,183,184,187,188。
2、联通号段有130,131,132,155,156,185,186,145,176。
3、电信号段有133,153,177.173,180,181,189。
*/
public static final String YD_STRING = "^[1]{1}(([3]{1}[4-9]{1})|([5]{1}[012789]{1})|([8]{1}[23478]{1})|([4]{1}[7]{1})|([7]{1}[8]{1}))[0-9]{8}$";
public static final String LT_STRING = "^[1]{1}(([3]{1}[0-2]{1})|([5]{1}[56]{1})|([8]{1}[56]{1})|([4]{1}[5]{1})|([7]{1}[6]{1}))[0-9]{8}$";
public static final String DX_STRING = "^[1]{1}(([3]{1}[3]{1})|([5]{1}[3]{1})|([8]{1}[09]{1})|([7]{1}[37]{1}))[0-9]{8}$";
public static final int YD = 1;
public static final int LT = 2;
public static final int DX = 3;
public static final int DEFAULT = -1;
/**
* 查询手机号运营商
*
* @param phoneNum
* @return 运营商类型
*/
public static int checkOperator(String phoneNum) {
if (phoneNum.length() == 11) {
if (phoneNum.matches(YD_STRING)) {
return YD;
} else if (phoneNum.matches(LT_STRING)) {
return LT;
} else if (phoneNum.matches(DX_STRING)) {
return DX;
}
}
return DEFAULT;
}
}