Is there a defacto way to parse this string `"(1,2...
# suitescript
m
Is there a defacto way to parse this string
"(1,234.56)"
into the negative number
-1234.56
?
format.parse()
doesn't seem to do it with types
CURRENCY
or
FLOAT
. Thoughts?
I'm doing this in a map/reduce script, so it looks like it's unable to use the User's format preference.
s
Idk if there is a defacto way, sounds like regex time to me
g
Wow, that seems like a terrible problem. Is there any other field on the record that you're looking at that might have the amount without the formatting? Otherwise, this thread had a nice clean function looked simple.
m
I'm reading data from a CSV, so no other fields that I could use. The function shown in that thread seems to be working for now. That's a good find, @GrayLeopard. Thank-you!!
g
Great, yea, it is logical to me.
r
Have you tried using the
N/format/i18n Module
? It has a
NumberFormatter
function
m
I had not tried that module, but it looks like it takes a number and returns a string with the desired format. I'm actually going the other way. I have the formatted string and want the corresponding number. Thanks, though!