I have a pricelist that I would like to 'normalize', using the Javascript flavor of Regex.
Sample input:
1
1,99
1.99
10
100
5999 dollars
2 USD
$2,99
Our price 2.99
Price: $ 20
200 $
20,-
6 999 USD
Desired output:
1
1,99
1.99
10
100
5999
2
2,99
2.99
20
200
20
6999
I am getting rather good results with /([0-9.,\s]+)/
but I've got two problems:
The last sample line returns
6
instead of6 999
. I am not sure if it's possible to "remove" the space, preferably I would like to get6999
but6 999
is close enough.Second last line returns
20,
(which is logical since I include commas) but rather want20
only in these cases.