问题
I have a string like this
"$2,099,585.43"
"$" maybe any symbol, like @,#..etc.
I want to convert this into 2099585.43
Is there any simple way to do this?
回答1:
Use String#replace and remove characters which are not a digit or dot.
console.log(
"$2,099,585.43".replace(/[^\d.]/g, '')
)
来源:https://stackoverflow.com/questions/38988364/how-to-convert-price-format-string-into-number-in-jquery