您的位置:首页 > 其它

如何判断手机号码格式是否正确

2017-02-17 11:58 302 查看
/**
* 验证手机号格式
*
* @param phone 需要验证的电话号码字符串
* @return true 正确 false 错误
* @author 武尊
* @version 1.0
* @time 2016-12-30
* @status 正常
*/
public static boolean isMobilephone(String phone) {
if (phone.startsWith("86") || phone.startsWith("+86")) {
phone = phone.substring(phone.indexOf("86") + 2);
}
Pattern p = Pattern.compile("^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\\d{8}$");
Matcher m = p.matcher(phone);
return m.matches();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: