public static boolean isEmailOK(String ... email) {
String regEx1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
Pattern p = Pattern.compile(regEx1);
if(email == null || email.length==0){
return false;
}
for (int i = 0;i < email.length; i++) {
Matcher m = p.matcher(email[i]);
if(!m.matches()){
return false;
}
}
return true;
}
public static void main(String[] args) {
String[] s = new String[]{"amy.wang@pernod-ricard.com"};
System.out.println(isEmailOK(s));
}
/*
* 对手机号码进行校验
* 中国移动:134(0-8)、135、136、137、138、139、1440(物联网)、147(上网卡)、148(物联网)、150、151、152、157、158、159、165(虚拟运营商)、170(3,5,6)(虚拟运营商)、172、178、182、183、184、187、188、195、197、198
* 中国联通:130、131、132、1400(物联网)、145(上网卡)、146(物联网)、155、156、166、167(虚拟运营商)、170(4,7,8,9)(虚拟运营商)、171(虚拟运营商)、175、176、185、186、196
* 中国电信:133、1349(卫星通信)、1410(物联网)、149(上网卡)、153、162(虚拟运营商)、170(0-2)(虚拟运营商)、173、174(00-05)(卫星通信)、177、180、181、189、190、191、193、199
*/
public static boolean isMobile(String mobile) {
String regex = "^((13[0-9])|(14[5|7|9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\\d{8}$";
// 创建一个匹配模式
Pattern p = Pattern.compile(regex);
// 返回matcher对象
Matcher m = p.matcher(mobile);
//判断是否匹配指定的字符串
return m.matches();
}