In MooTools More (1.4), there is a Number.format() function which takes a number and converts to a readable format, such as...
"5,003.2" === (5003.2).format()
.. considering the currently set Locale.
My question: Is there a possibility to have the reverse effect happen, e.g. for storing the plain numbers in a database? Something like:
5003.2 === "5,003.2".reverseformat()
Or do I have to use RegEx?
There isn't one that is readily available and it's not trivial. The string you have there is easy to do via regex but regex does not really tell you what the Locale is and what the custom format looks like.
For instance, seeing
5,300in the UK should go to a cool5300. In EU, it will often mean rounding to5.3.Having said that, see http://josscrowcroft.github.com/accounting.js/
it also supports
unformatwhich can bring it back.Trusting client Locale is general can also be
falsy, people travel with laptops... Though this is more applicable to Locale time/timezone stuff.