IF contains any number

datatable
excel
uiautomation
studio

#1

Hi All,

I would like to ask how can I do a if statement whether if the variable created to read a config contains any number?

Thanks.


#2

HI @jasperlzx,

you can use Is Match activity to check the string contains any number or not.

Pattern-> [0-9]

Regards,
Arivu


#3

hi,
the number will be 8 digit. Will this work?

thanks.


#4

@jasperlzx
if its always 8 digits you can try
[0-9]{8} or \d{8}
if its varying size,
[0-9]+ or \d+
If you know size can vary from one limit to other, e.g., 2 to 5
[0-9]{2,5} or \d{2,5}


#5

@jasperlzx Check attached file i think its useful

CheckNum.zip (1.8 KB)


#6

Hi @jasperlzx,

if its contain any single number it will return true value.

if you want to check exactly 8 digit number present means use below pattern.
Pattern-> [0-9]{8}

Regards,
Arivu