02-05-2019 07:16 AM - edited 03-14-2019 06:46 PM
Hi,
Can anyone give a simple example of checking if a variable string contains only numbers (for UCCX Script editor)?
I was unable to get "isNumeric" to work.
Gerry
Solved! Go to Solution.
02-05-2019 08:46 AM
I don't see isNumeric in the list of available methods for a String object. Where did you come up with that?
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
With the available methods in the Script editor drop down of Methods for Strings, ?.matches() seems to do the trick pretty easily:
Set test = "123" If (test.matches("[0-9]+")) True /* This string looks like an int */ False
Though, this isn't going to match a float/double types.
02-05-2019 08:46 AM
I don't see isNumeric in the list of available methods for a String object. Where did you come up with that?
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
With the available methods in the Script editor drop down of Methods for Strings, ?.matches() seems to do the trick pretty easily:
Set test = "123" If (test.matches("[0-9]+")) True /* This string looks like an int */ False
Though, this isn't going to match a float/double types.
02-05-2019 09:31 AM
Anthony,
Thank you very much. Tested and it works lovely.
Below is the IF node checking my variable "myStringVariable"
02-05-2019 11:55 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide