/**
* Created by Administrator on 2017/7/13.
* 手机号码校验
*/
public class PhoneCheck {
/**
* 验证号码 手机号
* 固话均可
*
* @param phoneNumber
* @return
*/
public static boolean isPhoneNumberValid(String phoneNumber) {
boolean isValid = false;
String expression = "((^(13|15|18)[0-9]{9}$)|(^0[1,2]{1}\\d{1}-?\\d{8}$)|(^0[3-9] {1}\\d{2}-?\\d{7,8}$)|(^0[1,2]{1}\\d{1}-?\\d{8}-(\\d{1,4})$)|(^0[3-9]{1}\\d{2}-? \\d{7,8}-(\\d{1,4})$))";
CharSequence inputStr = phoneNumber;
Pattern pattern = Pattern.compile(expression);
Matcher matcher = pattern.matcher(inputStr);
if (matcher.matches()) {
isValid = true;
}
return isValid;
}
}
android电话号码匹配
最新推荐文章于 2023-02-25 19:55:01 发布