js去除重複字串

iteye_3829發表於2013-05-17

function filterRepeatStr(str){
var ar2 = str.split(",");
var array = new Array();
var j=0
for(var i=0;i<ar2.length;i++){
if((array == "" || array.toString().match(new RegExp(ar2[i],"g")) == null)&&ar2[i]!=""){
array[j] =ar2[i];
array.sort();
j++;
}
}
return array.toString();
}

相關文章