Find Matching Patterns - position of results in text

Hi All,

I am using Find Matching Patterns activities to retrieve specific regex values from a text.
The result of the activity is a list with all of the results.
Is there a way to retrieve not just the regex result, but also the index position of the result in the text?

@erika027

You cannot directly retrive…

But after getting the value theough regex…you can use str.IndexOf("ExtractedString")

This way you can find the index

Cheers

My problem is that the Extracted string could be the same multiple times.
Like regex result list: [55,83,27,55,…] and I would need both 55 position within the long text.

Hi @erika027

Can you try the below

For Each (item in regexResultsList):
    Assign :
     index  = originalText.IndexOf(item)
    
    Log Message :
    "Regex Result: " + item.ToString() + ", Index Position: " + index.ToString()

Regards,

Hi @erika027

=> Find Matching Patterns
Output-> Matches

=> Use For Each loop to iterate through matches

For Each CurrentMatch in Matches
      WriteLine activity -> CurrentMatch.Index
End For Each

Regards

@erika027 - try this

Multiple Matches → Find Index of all → Perhaps Array(Int32)? - Help / Studio - UiPath Community Forum