public class StringTools { /** * 校验是不是email */ public static boolean checkIsEmail(String userId){ if(userId == null){ return false; }else{ String format = "\\w{1,}[@][a-z0-9]{1,}[.]\\p{Lower}{1,}"; return userId.matches(format); } } /** * 校验是不是手机号 * @param userId * @return */ public static boolean checkIsPhone(String userId){ if(userId == null){ return false; }else{ String format = "[1][0-9]{10,10}"; //1开头的11位数字 return userId.matches(format); } } }
02-24
932
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-09
12-09
6633
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)