3

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?

Manikandan Ram
  • 171
  • 1
  • 3
  • 11

1 Answers1

5

Use String#replace and remove characters which are not a digit or dot.

console.log(
  "$2,099,585.43".replace(/[^\d.]/g, '')
)
Pranav C Balan
  • 110,383
  • 23
  • 155
  • 178