How to find the placement of a string in an array knowing the value of the string that will always be after it

Hi all,

I am trying to do a for each loop to find out specifically what value a variable has in an array (read using ocr text)

I know that the line that always comes after it will contain a certain string that i can find using item.tostring.contains in a for each loop, my question is using that, how can i find the value of the string that comes before it in the array?

Thanks,
Harry

Hi @harryt,

Welcome to UiPath community!
If you are trying to get previous element before the match is found , you can find the element which you know it is appearing, get its index now by using this index as per your requirement you can access the previous elements.

If this is not what you are looking for, please explain a bit in detail.

Hi Shiva,

So i’m using the ‘read PDF with OCR’ activity and basically getting a large chunk of text seperated by new lines, which i am seperating by environment.newline. Since OCR is quite unreliable, sometimes it will put new lines of gibberish in between, changing the total index numbers and making the string i can find have a different index every time. I can find that index because the contents of that one are static, but the contents of the line I am looking for are not (although it is always before the static line)
Hope that makes sense.

Thanks for your help on this
Harry

Hi @harryt,

Can you share the sample of extracted data.
Are you trying to extract data before the static value or after the static value?

uipath 2

Hey Mate,

Because of security requirements I can’t actually upload the code but this is the general idea that i’m going for.

Cheers,
Harry

In case anyone is wondering how I eventually did it

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