用js取代數字與逗號以外的所有字元
//去掉第二個逗號
var reg=/,$/gi;str=str.replace(reg,"");
}
}
}else{
FCK.InsertHtm("[downsoft]ml dostr(strtemp) "[/downsoft]") ;}
function dostr(str){
str=trim(str);
var strarry=unique(str.split(","));
str=strarry.join(",") ;
str=str.replace(/,/ig,",");
str=str.replace(/[^0-9,]*/ig,"");
str= str.replace(new RegExp(', ',"gm"),',');
var reg=/,$/gi;
str=str.replace(reg,"");
return str;
}
//去重複陣列
function unique(data){
data = data || [];
var a = {};len = data.length; for . (var i=0; i
if (typeof(a[v]) == 'undef a[v] = 1;
(var i in a){
data[data.length] = i;
}
return data;
}
//供使用者呼叫
function trim(s){
return trimRight(trimLeft(s));
}
空白
function trimLeft(s){
if(s == null) {
return "";
}
var whitespace = new String(" tnr");
var str = new String(s);
if (whitespace.indexOf(str.charAt(0)) != -1) {
var j=0, i = str.length;
while (jj j ;
}
str = str.substring(j, i);
}
return str;
}
//去掉右邊的空白
function trimRight(s){
if(s == null) return "";
var whitespace = new String(" tnr ");
var str = new String(s);
if (whitespace.indexOf(str.charAt(str.length-1)) != -1){
var i = str.length - 1;
while (i >= 0 && whitespace.indexOf(str.charAt(i)) != -1){
i--;
}
str = str.substring( 0, i 1);
}
return str;
}