js指定の複数の分割文字を同じ配列に分割します.

561 ワード





var str=' ,,;;';//      
var test = 'iojhoijio,fewfe,oewf dfcwedf,wfew;gfgrer;dsfd';//       
var arr = new Array();
for(var i=0;i<test.length;i++){
	if(str.indexOf(test[i])>=0){
		arr.push(test.substring(0,i));
		test = test.substring((i+1),test.length);
		i=0;
	}else if(i==(test.length-1)){
		arr.push(test.substring(0,test.length));
	}
}
var n = '';
for(var i=0;i<arr.length;i++){
        n+="'"+arr[i]+"',"
}
n = n.substring(0,n.length-1);
document.write(n)