public boolean verifyPhone(String phone) {
String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
if (phone.length() != 11) {
System.out.println("手機號應為11位數");
} else {
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(phone);
boolean isMatch = m.matches();
if (isMatch) {
log.info("手機號格式正確");
return true;
} else {
log.info("手機號格式錯誤");
}
}
return false;
}
