javascript-Java脚本-Regex-使用希伯来语字符的密码验证

密码验证出现问题.
那是我的代码:

function validatePassword(){

    var password = document.getElementById("password").value;
    var re = /^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{6,16}$/;


 if(!password.match(re)){

      producePromt("The password is invalid","commandPasswordPrompt","red");
            return false;

 }
    producePromt("Password is OK","commandPasswordPrompt","green");
            return true;
}

它说它唯一无效,所以我认为这是因为正则表达式.
我问你是否可以在这里提供一切帮助.

非常感谢帮手!

解决方法:

尝试这个

// At least eight numbers or/and letters of English or Hebrew language
^[a-zA-Z0-9\u0590-\u05FF]{8,}$

要么

// At least eight characters: one number, one uppercase, one lowercase English letter and one Hebrew letter
^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[\u0590-\u05FF]).{8,}$

要么

// At least eight characters: one number and one uppercase of lowercase English or Hebrew letter
^(?=.*[0-9])(?=.*[a-z|A-Z|\u0590-\u05FF]).{8,}$

用法:

var p = /^(?=.*[0-9])(?=.*[a-z|A-Z|\u0590-\u05FF]).{8,}$/g;
var s = "שלוםWorld2";
if(!p.test(s)){
  console.log("Invalid password!");
}

Regex Demo | jsBIn Demo

上一篇:如何用Java加密/解密文件?


下一篇:实验3:OpenFlow协议分析实践