/**
* 24-03-13关键字模糊匹配
* 调用方法:fuzzyKeyWordMatch(str,key)
* @param str:字符串
* @param key:模糊匹配字符
* @returns {Boolean} true:匹配到关键字、false:未匹配到关键字
*/
function fuzzyKeyWordMatch(str, key){
var flagnum;
var index = -1;
flagnum = false;
for(var i = 0, arr = key.split(""); i < arr.length; i++ ){
//有一个关键字都没匹配到,则没有匹配到数据
if(str.indexOf(arr[i]) < 0){
break;
}else{
var match = str.matchAll(arr[i]);
var next = match.next();
while (!next.done){
if(next.value.index > index){
index = next.value.index;
if(i === arr.length - 1){
flagnum = true;
}
break;
}
next = match.next();
};
};
}
return flagnum;
}
06-27
8248
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-14
2940
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-16
5528
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-19
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交