How do I convert a currency string into just a decimal?

gigfreedom

New member
I am just trying to take a string captured by the AutoInput plugin and store the value as a decimal variable. Some of these incoming strings are weird and have shit like "Array: " in front of the float. I wanna do math and I unfortunately can't with the detected elements from AutoInput coming in as strings like "Array: $12.37"...
I need just the 12.37 numbers stored.
Could someone possibly point me in the right direction for this? Was messing with this all morning.
Thanks so much guys
 

Dm114

Well-known member
I am just trying to take a string captured by the AutoInput plugin and store the value as a decimal variable. Some of these incoming strings are weird and have shit like "Array: " in front of the float. I wanna do math and I unfortunately can't with the detected elements from AutoInput coming in as strings like "Array: $12.37"...
I need just the 12.37 numbers stored.
Could someone possibly point me in the right direction for this? Was messing with this all morning.
Thanks so much guys
It's quite easy. To extract decimal value, use Text manipulation > Extract text with following regex (\d+\.\d+) (tick Group 1 box).

This simple regex rule will match any decimal numbers. If you have several number elsewhere in the string, tell us more to improve the rule.

Hope it'll help.
 

gigfreedom

New member
Ok so that actually got most of everything working the way I want it to!!! Thanks so much. The only other thing I need to get rid of is the dollar sign just for when I'm doing the math then I want to be able to add the dollar sign back to the number after the math is done. Sooooo appreciate your help! Thanks again!

EDIT: NVM I GOT IT!! :)))) Thanks for the help.
I have been learning to code lately so if it's not too much to ask, could you possibly explain what regex and the "(\d+\.\d+)" means?
 
Last edited:

Dm114

Well-known member
Once you extract the decimal string (see attached), store it in a decimal variable with the following Magic text/function
[strval=String_variable]

Then do the calculation you have to do and store the result in String_variable like this:
USD [lv=String_variable]
or
$[lv=String_variable]
 

Attachments

  • 20220611_221812.jpg
    20220611_221812.jpg
    294 KB · Views: 22
Last edited:
Top