1
如何在二維數組中搜索並將數組列表作爲數組返回?在二維數組中搜索並將數組列表作爲數組返回
var dataSet = new Array(new Array());
function searchAsset(){
dataSet.length = 0;
var fileName = document.getElementById("fileName").value;
var arr = new Array(["view_page.psd","test"],["ok_test.jpg","yes","kk"],["new_banner_2009.fla","good"],["gps-new-web.html","hot"]);
var re = new RegExp(fileName ,'i');
var res = null;
for(var i = 0;i<arr.length;i++){
var newArr = arr[i][0];
//alert(newArr+":"+newArr.match(re));
var res = newArr.match(re);
if(res != null){
dataSet.push("["+arr[i]+"]");
}
}
alert("Final --- "+dataSet);
for(var m = 0;m<dataSet.length;m++){
alert(dataSet[m]);
}
}
不要粘貼HTML,只是代碼,並使用代碼格式 – 2010-02-19 06:51:43