关于手机号和密码的正则表达式

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);

returnmatcher.matches();

 }


public static boolean isPhone(String phone)

 String check ="^(((13[0-9])|(14[579])|(15([0-3]|[5-9]))|(16[6])|(17[0135678])|(18[0-9])|(19[89]))\\d{8})$"; 

 Pattern regex = Pattern.compile(check); 

 Matcher matcher = regex.matcher(phone);

returnmatcher.matches();

 }

}

摘自:https://www.jianshu.com/p/4ff967ad5d17

你可能感兴趣的:(关于手机号和密码的正则表达式)