I need to parse some data that contains comma formatted numbers and text like this, keeping only numerical part:
"The stock is 1,124 units"
I came up with this regex that is working great, except for numbers under 0, example a price that could be 0,259 EUR
qty = qty.textContent.replace(/\D/g,'');
How can I modify for removing only text, but still keeping the sense of original number
I'd like -> 0.259 Not -> 0259
EDITED
I need both situations, thousands separator and decimal place.
Depending on parse, could be USD when comma is thousands separator, or EUR, where dot is decimal place. I will make a switch case for currency and thank you for your fast answers!