private String isPhoneNo(String phoneNo) {
phoneNo = toDBC(phoneNo.trim());
if (matchRegex(phoneNo, "^1[34578]{1}[0-9]{9}$") || matchRegex(phoneNo, "^[+]{1}86[-]{1}1[34578]{1}[0-9]{1}[-]?[0-9]{8}$")
|| phoneNo.matches("^01[34578]{1}[0-9]{9}$")) {
// 三种现有参与识别的手机格式13388889999/17388889999 ; +86-13388889999 ;
// +86-133-88889999
if (phoneNo.length() == 11) {
return phoneNo;
} else if (phoneNo.length() == 15) {
return phoneNo.substring(4);
} else if (phoneNo.length() == 13 && "0".equals(phoneNo.substring(0, 1))) {
return phoneNo.substring(1);
} else if (phoneNo.length() == 12) {
return phoneNo.substring(1);
}
} else {
return "1";
}
return phoneNo;
}
public static boolean matchRegex(String telNoTemp, String patternStr) {
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(telNoTemp);
if (matcher != null && matcher.matches()) {
return true;
} else {
return false;
}
}