数组 迷糊搜索
function searchList(str,container){
var newList =[];
//新的列表
var startChar = str.charAt(0);
//开始字符
var strLen = str.length;
//查找符串的长度
for(var i = 0;i < container.length;i++){
var obj = container[i];
var isMatch = false;
for(var p in obj){
if(typeof(obj[p])== "function"){
obj[p]();
} else {
var curItem = "";
if(obj[p]!= null){
curItem = obj[p];
}
for(var j = 0;j < curItem.length;j++){
if(curItem.charAt(j)== startChar)
{
if(curItem.substring(j).substring(0,strLen)== str)
{
isMatch = true;
break;
}
}
}
}
}
if(isMatch){
newList.push(obj);
}
}
return newList;
}
---------------------
网友评论