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
  • 211
  • 1
  • 4
  • 12

1 Answers1

7

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
  • 113,687
  • 23
  • 165
  • 188