手机号码目前市场上的主要有13(0-9)、147、171、177、15(^4,\\D)、18(0-9)开头的手机号码!如果有其他特殊的可以自己添加
- <span style="font-size:18px;">/**
- * 判断是否是手机号码
- *
- * @param mobiles
- * 手机号码
- * @return
- */
- public static boolean isMobileNO(String mobiles) {
- Pattern p = Pattern
- .compile("^((13[0-9])|(147)|(171)|(177)|(15[^4,\\D])|(18[0,1,2,3,4,5-9]))\\d{8}$");
- Matcher m = p.matcher(mobiles);
- return m.matches();
- }
- /**
- * 验证输入的邮箱格式是否符合
- *
- * @param email
- * @return 是否合法
- */
- public static boolean emailFormat(String email) {
- boolean tag = true;
- final String pattern1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
- final Pattern pattern = Pattern.compile(pattern1);
- final Matcher mat = pattern.matcher(email);
- if (!mat.find()) {
- tag = false;
- }
- return tag;
- }</span>