Check if value contains a number

Hello,

How can i check a value contains a number ?

Example something like this ? output_matches.ToString.Contains( integer ?)

@mz3bel

Try this in IF condition.

isNumeric(“String”)

5 Likes

Hi @mz3bel,

Use IsNumeric key word to check whether the string contains numbers or not. For this you need to loop through the length of the string and check whether the character is numeric or not

1 Like

hi,

  1. if you need the boolean value go with ISMATCH activity and give the pattern as “[\d]”
    this will return the boolean value
  2. if you need the number from the text then go with MATCHES activity and give the same pattern that will return you the number
2 Likes

@lakshman

Like this isNumeric(“output_matches(0)”) ? Tested it returns FALSE!

I want to check the result of a regex code… which should return me only numbers… and it does!

1 Like

@mz3bel

Yes.

Try this: System.Text.RegularExpressions.Regex.IsMatch(“string”,"[0-9]")

7 Likes

@ashley11

I already did the matches activity to get the number from a text… but now i ve to test if it’s a number or not?

In fact the idea is that i use putty, i use than get visible text to get the text than matches to extract what i need… and since putty or linux sometimes takes some time to show, so i did a while loop, to check if the value is numeric or not so it has to wait untel it shows the value than proceed…

1 Like

@mz3bel

If whole string is Numeric than it will return True else will return false.

1 Like

@lakshman

IT WORKS!

Thank you

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.