Jump to content
UBot Underground

How to tell number?


Recommended Posts

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.

  • Like 1
Link to post
Share on other sites
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+$ 
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...