手机号正则验证

javascript


function checkPhone(phone){
if (!(/^1[3|4|5|7|8]\d{9}$/.test(phone))) {
return false
}
return true
}

Java


public static boolean checkPhone(String phone){
Pattern p= Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$");
Matcher m = p.matcher(phone);
return m.matches();
}

你可能感兴趣的:(手机号正则验证)