sifuhall 0 Posted June 29, 2013 Report Share Posted June 29, 2013 I would like to return true if number and false if not. For example: 1 would return truea would return false How can I do this? Quote Link to post Share on other sites
UBotDev 276 Posted June 29, 2013 Report Share Posted June 29, 2013 You can try with regular expression: \d+ and check the length of returned string. If lenght > 0 then you have a number, else you don't. 1 Quote Link to post Share on other sites
sifuhall 0 Posted June 29, 2013 Author Report Share Posted June 29, 2013 Thank you Quote Link to post Share on other sites
danoctav 7 Posted June 29, 2013 Report Share Posted June 29, 2013 ui text box("Enter data:", #var) set(#var, $find regular expression(#var, "[-+]?\\b[0-9]+(\\.[0-9]+)?\\b"), "Global") if($comparison(#var, "!=", $nothing)) { then { set(#isnumber, "true", "Global") } else { set(#isnumber, "false", "Global") } } ui stat monitor("Number? ", #isnumber) where regex is for an integer or a floating point number, positive or negative . For a simple integer (with sign .... positive or negative) : ^[-+]?\d+$ 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.