邮箱正则:shuzf@163.com.cn
^[A-Za-z0-9u4e00-u9fa5]+@[a-zA-Z0-9_-]+(.[a-zA-Z0-9_-]+)+$
^ 由于邮箱的基本格式为“名称@域名”,需要使用“^”匹配邮箱的开始部分
A-Za-z0-9 大小写数字
u4e00-u9fa5 汉字
@[a-zA-Z0-9_-]+ @**
(.[a-zA-Z0-9_-]+)+ 多个.**
$ 用“$”匹配邮箱结束部分以保证邮箱前后不能有其他字符
手机号正则:17012345678
^(((13[0-9])|(14[579])|(15([0-3]|[5-9]))|(16[6])|(17[01235678])|(18[0-9])|(19[89]))\d{8})$
13[0-9]
14[579]
15[0-3]
16[6]
17[0135678]
18[0-9]
19[89]
d{8}后8位
public class CheckFormat { public static boolean isEmail(String email){ 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); return matcher.matches(); } public static boolean isPhone(String phone){ String check = "^(((13[0-9])|(14[579])|(15([0-3]|[5-9]))|(16[6])|(17[01235678])|(18[0-9])|(19[89]))\d{8})$"; Pattern regex = Pattern.compile(check); Matcher matcher = regex.matcher(phone); return matcher.matches(); } }
2019年8月发布172号段