Home > Back-end >  i want to remove coma and plus ( ) operator from a string
i want to remove coma and plus ( ) operator from a string

Time:08-15

I want to remove plus( ) sign and coma from a string. here is the code.

actualValue.push(parseFloat(wholeValues[i].replace(/,/g, '')))

CodePudding user response:

wholeValues[i].replace(/[ ,]/g, '')

or

wholeValues[i].replace(/,/g, '').replace(/ /g, '')

The first one is faster a little bit

CodePudding user response:

You just need to replace twice.

const value = parseFloat(wholeValues[i].replaceAll(',', '').replaceAll(' ', ''))
actualValue.push(value)
  • Related