/** * 正则表达式 判断手机号是否正确 */ public static boolean isPhoneNum(String num) { Pattern p = Pattern.compile("^(((13[0-9])|(15([0-9]))|(18[0-9]))\\d{8})$"); Matcher m = p.matcher(num); return m.matches(); }
/** * 正则表达式 判断电话号是否正确 */ public static boolean isPhoneHomeNum(String num) { Pattern p = Pattern.compile("^(((13[0-9])|(15([0-3]|[5-9])|170)|(18[0,5-9]))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{8})$"); Matcher m = p.matcher(num); return m.matches(); }
/** * 验证邮箱 * * @param email * @return */ public static boolean checkEmail(String email) { boolean flag = false; try { String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; Pattern regex = Pattern.compile(check); Matcher matcher = regex.matcher(email); flag = matcher.matches(); } catch (Exception e) { flag = false; } return flag; }