Java匹配国内手机号码段

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

移动号段:
134 135 136 137 138 139 147 150 151 152 157 158 159 178 182 183 184 187 188html

联通号段:
130 131 132 145 155 156 171 175 176 185 186java

电信号段:
133 149 153 173 177 180 181 189
虚拟运营商:
170apache

参考http://www.cnblogs.com/zengxiangzhan/p/phone.html工具

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

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;
	}

}
相关文章
相关标签/搜索