Based off a simlar question asked here - How to convert a currency string to a double with jQuery or Javascript?, I need to take a currency that can be in the format of
-143,000.00 and convert it for 2 scenarios:
- Where the output would be -143000.00
- Where the output would be -1430000
I am not good at all with regular expressions so I have tried some hack such as these 2 below:
- I need to remove all of the currency except for the
-
const value = "-143,000.00";
Number(value.replace(/[^0-9.,]+/g, ''))
and my second use case is I need to remove all but keep the -
and the .
const value = "-143,000.00";
Number(value.replace(/[^0-9.-]+/g, ''));
Thank you for assistance that you can give.