SoFunction
Updated on 2025-03-01

Replace all characters except numbers and commas with js

//Deduplicate array
function unique(data){
    data = data || [];
    var a = {};
len = ;
    for (var i=0; i<len;i++){
 var v = data[i];
        if (typeof(a[v]) == 'undefined'){
                               a[v] = 1;
                               }
    };
    =0;
      for (var i in a){
               data[] = i;
         }
        return data;
}
//For users to call
function trim(s){
return trimRight(trimLeft(s));
}
//Remove the blank on the left
function trimLeft(s){
if(s == null) {
return "";
}
var whitespace = new String(" \t\n\r");
var str = new String(s);
if (((0)) != -1) {
var j=0, i = ;
while (j < i && ((j)) != -1){
j++;
}
str = (j, i);
}
return str;
}
//Remove the blank on the right
function trimRight(s){
if(s == null) return "";
var whitespace = new String(" \t\n\r");
var str = new String(s);
if (((-1)) != -1){
var i = - 1;
while (i >= 0 && ((i)) != -1){
i--;
}
str = (0, i+1);
}
return str;
}