/** * * 判断是否是邮箱 * * @param mobile 手机号码 * @return boolean */ public static boolean isEmail(String email) { if (email==null||email.equals("")) { return false; } String check = "^(\\w+((-\\w+)|(.\\w+))*)+\\w+((-\\w+)|(.\\w+))*@([0-9a-z]+(\\.[a-z]{2,})+)$"; Pattern regex = Pattern.compile(check); Matcher matcher = regex.matcher(email); return matcher.matches(); } /** * * 判断字符串是否是手机号码 * * @param mobile 字符串 * @return boolean */ public static boolean isMobile(String mobile) { boolean isMobile = Boolean.FALSE; try { Long.parseLong(mobile); isMobile = Boolean.TRUE; } catch (NumberFormatException nfe) { isMobile = Boolean.FALSE; } if (mobile.startsWith("1") && 11 == mobile.length()) { isMobile = Boolean.TRUE; } else { isMobile = Boolean.FALSE; } return isMobile; }