正则表达式匹配

邮箱验证:

private static Boolean checkEmail(String email) {
if (email.matches("1+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\.)+[a-z]{2,}KaTeX parse error: Expected 'EOF', got '}' at position 46: …eturn false; } }̲ 手机号验证: public …";
return check(cellphone, regex);
}

/**

  • 验证固话号码
  • @param telephone
  • @return
    */
    public static boolean checkTelephone(String telephone) {
    String regex = “^(0\d{2}-\d{8}(-\d{1,4})?)|(0\d{3}-\d{7,8}(-\d{1,4})?)$”;
    return check(telephone, regex);
    }

  1. a-z0-9A-Z ↩︎

上一篇:常用正则表达式


下一篇:常用js正则表达式大全