zoukankan      html  css  js  c++  java
  • 邮箱手机号正则

    
    

    邮箱正则:shuzf@163.com.cn

    ^[A-Za-z0-9u4e00-u9fa5]+@[a-zA-Z0-9_-]+(.[a-zA-Z0-9_-]+)+$
    ^ 由于邮箱的基本格式为“名称@域名”,需要使用“^”匹配邮箱的开始部分
    A-Za-z0-9 大小写数字
    u4e00-u9fa5 汉字
    @[a-zA-Z0-9_-]+ @**
    (.[a-zA-Z0-9_-]+)+ 多个.**
    $ 用“$”匹配邮箱结束部分以保证邮箱前后不能有其他字符

    
    


    手机号正则:17012345678

    ^(((13[0-9])|(14[579])|(15([0-3]|[5-9]))|(16[6])|(17[01235678])|(18[0-9])|(19[89]))\d{8})$
    13[0-9]
    14[579]
    15[0-3]
    16[6]
    17[0135678]
    18[0-9]
    19[89]
    d{8}后8位

    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);
            return matcher.matches();
        }
    
        public static boolean isPhone(String phone){
            String check = "^(((13[0-9])|(14[579])|(15([0-3]|[5-9]))|(16[6])|(17[01235678])|(18[0-9])|(19[89]))\d{8})$";
            Pattern regex = Pattern.compile(check);
            Matcher matcher = regex.matcher(phone);
            return matcher.matches();
        }
    }

    2019年8月发布172号段

  • 相关阅读:
    XML和HTML中常用转义字符:
    特殊符号大全
    CSS规范
    兼容ie6,ie7,ie8,firefox,chrome浏览器的代码片段
    模拟select选择器
    一行代码解决IE6/7/8/9/10兼容问题
    响应式页面之秘籍
    Global 全局样式基本设置
    webAPP meta 标签大全
    随笔小计 --
  • 原文地址:https://www.cnblogs.com/shuzf/p/11412529.html
Copyright © 2011-2022 走看看