I would need to write a RegExp in AS3 which parses an Excel formatted currency value into a number: E.g. RegExp($35,600.00) = 35600
And checks if it is correctly formatted (with the "," as the thousands separator, and the "." as the decimal point. The currency symbol could be any (not just $) and could stand at the beginning or the end.
So I would just need to strip every non digit from the number and check if is valid.
Thanks! Martin
You will need two cases, one for comma as separator and another for decimal separated whole numbers.
If a whole number, remove everything after the comma or decimal point(depending on your format). Then run the following Regex:
This will remove all non-digit characters:
s/\D+//g;
If you do not have a whole number, you will need to include an exception for the whole number separator:
Decimal separator:
s/[^\d.]+//g
Comma separator:
s/[^\d,]+//g
*Disclaimer: I only parsed these regexes in my head, so my syntax could be slightly off.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With