Check If String Contains given No

Hii Team,

We are extracting String

ValueExtracted=“Found 0 items”

Example if given as below

Found 0 items

Then it should be True

Else

False

Have tried approach using keyword with Contain

But then if string would be
“Found 100 items” then also it returns true which is incorrect

It should only be true if 0 items are there

Thanks team in Advance

Hi!

Why don’t you just use ValueExtracted.Equals(“Found 0 items”) ?

Hi @NISHITHA

You can use the below expression to get the True or False,

- Assign -> Input = "Found 0 items"

- Assign -> Bool_Flag = If(Input.toString.tolower.equals("found 0 items"), True, False)

Bool_Flag is the boolean datatype variable which gives if Found 0 items then it will give True else False.

Check the below image for better understanding,

Hope it helps!!

Hie @NISHITHA you can use if condition and inside if pass your variable if it equals then it true otherwise it goes false
image

cheers Happy Automation. :grin:

Another way is to use regex to remove all other than numbers.
System.Text.RegularExpressions.Regex.Replace(string_Variable,“\D”,“”)

The advantage is that you are not affected if the text changes

Example from “Found 0 items” to

  • “Found 0 products”
  • “Found 0 results”
  • “Found 0 entries”
  • “Found 0 records”

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