/**
* 正则表达式工具类
*
* @author user
*
*/
public class RegularExpressionUtil {
/**
* 邮箱正则(只允许后缀名是verizonwireless.com /xposc.com /asurion.com)
*/
public static final String REGEX_MAIL =
"^[A-Za-z\\d.\\-_ /*!]+@((verizonwireless.com)|(xposc.com)|(asurion.com))?";
// "^[\\s\\S][^\\&]+@((verizonwireless.com)|(xposc.com)|(asurion.com))?"(@前不允许&,其余都允许)
/**
* 密码正则 (只允许大于8个字符,至少有一个数字,至少有一个字母,至少有一个特殊字符)
*/
public static final String REGEX_PASSWORD =
"^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[`~!@#$%^&*()+=|{}':;',\\\\[\\\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?])[A-Za-z\\d`~!@#$%^&*()+=|{}':;',\\\\[\\\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]{8,}";
public static boolean isMatch(String checkStr, String regEx) {
Pattern pattern = Pattern.compile(regEx);
Matcher matcher = pattern.matcher(checkStr);
boolean matches = matcher.matches();
return matches;
}
public static void main(String[] args) {
String email = "dwdaw.1-/2!*@xposc.com";
boolean match = RegularExpressionUtil.isMatch(email, REGEX_MAIL);
System.out.println(match);
}
}