Extract number from webpage string regular expression

I’m building an automation using a Public Website. Below is a list of steps to get to my issue. For every search i do the result number will be different and depending on the number in the results between the to and of there will be conditions. if extracted number is < 100 then perform these actions, if number is > 100 perform these actions, etc… If anybody can give me a good solutions to just isolate that number from the string that would be great. the number can range between 0 and 900

  1. URL-Welcome to MID :: provided by vPIC - MID
    2.Type 955 in the Manufacturer ID box
    3.uncheck Part 566 check box
  2. Click Search
  3. Choose 100 from the show entries box
  4. scroll down and find the following result string “Showing 1 to 22 of 22 entries” i need the number between the to and the off and i need it to be a integer once its extracted.

Hi @NATHAN_MORA ,

Could you try using the below Regex Expression :

(\d+)\s+to\s+(\d+)\s+of\s+(\d+)

Expression :

FirstEntryNumber = System.Text.RegularExpressions.Regex.Match(ExtractedString,"(\d+)\s+to\s+(\d+)\s+of\s+(\d+)",RegexOptions.IgnoreCase).Groups(1).Value

LastEntryNumber = System.Text.RegularExpressions.Regex.Match(ExtractedString,"(\d+)\s+to\s+(\d+)\s+of\s+(\d+)",RegexOptions.IgnoreCase).Groups(2).Value

TotalEntries = System.Text.RegularExpressions.Regex.Match(ExtractedString,"(\d+)\s+to\s+(\d+)\s+of\s+(\d+)",RegexOptions.IgnoreCase).Groups(3).Value

Let us know if the above doesn’t work.

Thanks looks good, now i just need to convert that number to an integer correct? thanks for this

@NATHAN_MORA ,

That is correct, You could directly use the function to convert to an Integer in the above Expression by using CInt() to the whole expression and keeping the variables as an Integer type.

could you provide how to do that with an assign activity? my string value is called output

@NATHAN_MORA

Create a variable of type integer and then in assign on left give the variable on right provide Cint(Output)

Hope this helps

Cheers

1 Like

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