addamroy 36 Posted July 21, 2014 Report Share Posted July 21, 2014 I have a script that generates a dollar value as a result after some hefty calculations. IE $1299.99 My problem is the results are showing with like 10 decimals, for example I might get a result like 19.8888399221 Is there any way to strip any extra decimal after the second one to make it normal again? For example the above would become 19.88 ... like a dollar value should be displayed Thanks! Quote Link to post Share on other sites
UBotDev 276 Posted July 21, 2014 Report Share Posted July 21, 2014 Use function find regular expression with regex like: \d+(?=\.\d*)You could also use function replace regular expression with regex like: \.\d* and replace it with nothing. Quote Link to post Share on other sites
addamroy 36 Posted July 21, 2014 Author Report Share Posted July 21, 2014 I have never used REGEX can you please explain to me how to use that code and the logic behind it so I understand what it's doing and how it works?? Quote Link to post Share on other sites
UBotDev 276 Posted July 21, 2014 Report Share Posted July 21, 2014 In one sentence, regular expression is used to extract data from strings. In UBot you would use it like this: set(#INTEGER, $find regular expression(1299.99, "\\d+(?=\\.\\d*)"), "Global") Quote Link to post Share on other sites
rocket976 62 Posted July 22, 2014 Report Share Posted July 22, 2014 set(#example, $substring(12.7333, 0, 5), "Global")Also works. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.