Java && js正则表达式收集(随时更新)

一、邮箱格式正则校验

1、Java正则验证邮箱

public static void main(String[] args) {
        String regEx1 = "^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$";
        Pattern p = Pattern.compile(regEx1);
        Matcher m = p.matcher("test");
        if(m.matches()){
            System.out.println(true);
        }else{
            System.out.println(false);
        }
    }

2、JS正则验证邮箱

var reg= /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
var mail = 'test@1.co';
console.log(reg.test(mail));

参考链接:https://blog.csdn.net/a913858/article/details/82999890

原文地址:https://www.cnblogs.com/steveshao/p/13530927.html