How can I convert currency string like this $123,456,78.3 to number like this 12345678.3
I tried to do using this pattern
let str = "$123,456,78.3";
let newStr = str.replace(/\D/g, '');
but it replaces . too.
How can I convert currency string like this $123,456,78.3 to number like this 12345678.3
I tried to do using this pattern
let str = "$123,456,78.3";
let newStr = str.replace(/\D/g, '');
but it replaces . too.
Use a lowercase d, and put it into a negated character group along with the ..
let str = "$123,456,78.3";
let newStr = str.replace(/[^\d.]/g, '');
console.log(newStr)