为什么“g”修饰符在这种情况下不起作用?我认为用逗号分隔变量并添加“g”是将匹配设置为全局匹配的可接受方式?
str = "cabeca";
testcases = [];
x = 0;
for (i = 0; i < str.length; i++) {
testcases = str[i];
x = i + 1;
while (x < str.length) {
testcases += "" + str[x];
if (str.match((testcases),"g").length >= 2) {
console.log(testcases);
}
x++;
}
}
当前演示(仍然无法正常工作)http://jsfiddle.net/zackarylundquist/NPzfH/