How to escape ':', "," and '()' under javascript array which supports both window and linux? -
i have javascript array special characters getting populated back-end database. wanted escape characters on front-end form query string results properly. array shown below:
var = new array(); a[0] = "abc,def"; a[1] = "abc:def"; a[2] = "abc(def)";
my query string formation shown below:
http://localhost:8080/search/?ar=and(or(category1:abc,def),or(category2:abc:def),or(category3:abc(def)));
my query string parameter getting separated ':" character, data having ':' characters failing query results. triend encodeuricomponent() in-built functions, fails in linux box.escape special characters should support both window , linux well. on this?
i not sure if understood problem. if want escape characters array, can soemthing this.
var = new array(); a[0] = "abc,def"; a[1] = "abc:def"; a[2] = "abc(def)"; var excplist = [',',':','(', ')']; var res = a.map(function(item,index,array){ return item.split('').filter(function(item,index,array){ if(excp.indexof(item) < 0){ return item; } }).join(''); });
res --> ["abcdef", "abcdef", "abcdef"]
Comments
Post a Comment