abrar22
9 years agoFrequent Contributor
Trim Special Characters from Numbers
Hi,
I want to remove special characters from number. Can I use replace function ?
var Notional= Getter.vGetPropertyVal(WTbx_SingleLegNotional,'Text');
var Desired= Notional.replace(/[!@#$%^&*]/g, "");
Its coming as 1,000,000. But I want to trim all , from the number. Using above function I am gettign run time error. ANy suggestions?
You can try using this:
var Notional= Getter.vGetPropertyVal(WTbx_SingleLegNotional,'Text');
var Desired= Notional.replace(/\D/g, "");This code works as shown below
function ReplaceSpChr(){ var s = "/[!@2#$4%^&1*]0/g00,0"; // Create regular expression pattern. var re = /\D/g; // Use replace var r = s.replace(re, ""); return(r); // Output: 2410000 }