我如何将这种货币字符串转换$123,456,78.3
为12345678.3
我尝试使用此模式进行的数字转换
let str = "$123,456,78.3";
let newStr = str.replace(/\D/g, '');
但它也取代.
了。
var str = "$123,456,78.3";
var newStr = Number(str.replace(/[^0-9.-]+/g,""));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句