How to convert price format string into number in jquery [duplicate]

谁都会走 提交于 2020-07-07 09:26:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!