下面是一段java代码功能,我想把他改成js代码请问如何改才好 public static boolean isValidatePassword(String str)
{
String REG_PATTERN = "^\\w{8,12}$";
Pattern pattern = Pattern.compile(REG_PATTERN);
Matcher matcher = pattern.matcher(str);
if (matcher.matches())
{
for (int i = 0; i < str.length() / 2; i++)
{
if (str.replaceAll(str.substring(0, i + 1), "").length() == 0)
{
return false;
}
}
return true;
}
return false;
}
{
String REG_PATTERN = "^\\w{8,12}$";
Pattern pattern = Pattern.compile(REG_PATTERN);
Matcher matcher = pattern.matcher(str);
if (matcher.matches())
{
for (int i = 0; i < str.length() / 2; i++)
{
if (str.replaceAll(str.substring(0, i + 1), "").length() == 0)
{
return false;
}
}
return true;
}
return false;
}
string pattern = /^\w{8,12}$/;
if(pattern.text(str) {
for(var i = 0; i < str.length/2; i++) {
if(str.replace(str.substring(0,i+1),"").length == 0) {
return false;
}
}
return true;
}
}
string pattern = /^\w{8,12}$/;
if(pattern.text(str) {
for(var i = 0; i < str.length/2; i++) {
if(str.replace(str.substring(0,i+1),"").length == 0) {
return false;
}
}
return true;
}
return false;
}
var pattern = /^\w{8,12}$/;
if(pattern.test(str) {
for(var i = 0; i < str.length/2; i++) {
if(str.replace(str.substring(0,i+1),"").length == 0) {
return false;
}
}
return true;
}
return false;
}
var pattern = /^\w{8,12}$/;
if(pattern.test(str) {
for(var i = 0,len = str.length/2; i < len; i++) {
if(str.replace(str.substring(0,i+1),"").length == 0) {
return false;
}
}
return true;
}
return false;
}