【正则表达式】密码8-16个字符,必须包含数字、大写字母、小写字母中的2种字符

密码规则:密码8-16个字符,必须包含数字、大写字母、小写字母中的2种字符

  passwordCheck= (rule, value, callback)=>{
    const pass = /(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[a-z])(?=.*[A-Z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[0-9])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[0-9])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[a-z])(?=[0-9]))|((?=.*[A-Z])(?=.*[0-9])(?=[a-z]))|((?=.*[a-z])(?=.*[A-Z])(?=[0-9]))|((?=.*[a-z])(?=.*[0-9])(?=[A-Z]))|((?=.*[0-9])(?=.*[A-Z])(?=[a-z]))|((?=.*[0-9])(?=.*[a-z])(?=[A-Z])))^[a-zA-Z0-9]{8,16}$/gm
    if (!pass.test(value)) {
      callback('密码8-16个字符,必须包含数字、大写字母、小写字母中的2种字符');
    }else{
      callback()
    }
  }

你可能感兴趣的:(React,正则表达式)