Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 3

Check string contains number between 0-9

I writing in installscript and looking for a simply way to check if string contains number between 0-9.

Thanks in advance....
Labels (1)
0 Kudos
2 Replies
Level 7

If you know that the string is a string representation of a number (and does not include none number characters) then use StrToNum() to convert the string to a number and thest the value of the number. See:

StrToNum(nNumber, szString);
if (nNumber > 0 && nNumber < 9) then something

If the string has none number characters and you can divide the string into a substring, then do that first to isolate the number to a string, and take the above approach.

If the string is random characters which you cannot isolate into a substring of numbers, then I guess you would need to test for each numeric character in the range of concern.

szString = "asgeag4asdgga"
if (szString % "4") then
..includes a "5" character
elseif (szString % "5") then
..includes a "5" character
elseif ((szString % "4") || (szString % "5")) then
..includes either 4 or 5 characters
0 Kudos
Level 3

Thanks for your replay.
StrToNum is good enought.
But the problem that you look for a number between 0 and 9
I can get a number like 20000
And want to check if it contains number in it vs contains Alphabets or something like that.
Thanks in advance...
0 Kudos