有时候正则表达式可以大大提高我们的开发效率呢
比如这段校验基本日期格式的javascript代码:
let d1 = 2017/12/10;
let r1 = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;
let r = d1.match(r1);
if(r == null){
console.log(日期格式错误!);
}else{
console.log(通过~);
}
1、校验密码强度
密码的强度必须包含大小写字母和数字的组合,不能使用特殊符号,长度在8-10之间:
^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])