I’d like to share my workflow on how I have gotten a specific number from a website which coudn’t be gathered with any string manipulation but with using regex.matches.
The problem was that the string was either “1–16 von 117 Ergebnissen” or " 1 Ergebnis" and i needed only the last number for the further workflow.
E.g. 117 or 1.
I have scraped the text from a website with the get text activity. Then I have used the regex.matches activity to extract only digits with a length of at least 1.
RegexPattern -> “(\d+)”
Result = Reg_FoundCounterMatches
After doing so, while in debugging mode, I can see that 3 items have been captured and are now stored in the Result.
First the length of the Reg_FoundCounterMatches is needed in a variable, to use it as an Index for finding the last item of the Reg_FoundCounterMatches.)
FoundCounterMatches_Length = Reg_FoundCounterMatches.count (as int32)
Keeping in mind that the last item of the regex collection has to be found and that the regex.matches is a zero-based collection but the counted length is not, the FoundCounterMatches_Length has to be decreased by 1.
LastItemCounter=FoundCounterMatches_Length-1 (as Int32)
The Solution is:
Conversion to String in brackets has to be done so that the conversion to Int32 will be successful.
I hope it will help at occasion