其中包含了phone,email等
public class CommonRegUtils {
public final static String emailRegx = "^[\\w-\\.]+@[\\w-]+(\\.+[\\w-]+)?(\\.+[a-zA-Z\\-]+)+$";
public final static String phoneRegx = "^1[3-9]{1}[\\d]{9}$";
public final static String emptyStr = "\\s+";
public final static String numRegx = "^[0-9]+$";
public static boolean isEmail(String email) {
if (email == null || email.isEmpty()) {
return false;
}
email = email.replaceAll(emptyStr, "");
if (email.matches(emailRegx)) {
return true;
}
return false;
}
public static boolean isPhone(String phone) {
if (phone == null || phone.isEmpty()) {
return false;
}
phone = phone.replaceAll(emptyStr, "");
if (phone.matches(phoneRegx)) {
return true;
}
return false;
}
public static boolean isNum(String num) {
if (StringUtils.isEmpty(num)) {
return false;
}
num = StringUtils.trim(num);
if (num.matches(numRegx)) {
return true;
}
return false;
}
}