更新时间:2023-02-26 12:35:32
您必须先将字符串解析为数字,然后才能将其相乘:
You have to parse string as a number before you can multiply it:
str = str.replace(/[0-9]+(?:\.[0-9]*)?/g, function(m) { return 2*parseFloat(m)+''; });
您不能在javascript中将字符串相乘!
You cannot multiply strings in javascript !
"" * 2 // NaN