Select second item in string

Hi All

I am trying to data scrape a text file. What i do is read the text file into a string then search a string in a line and display that line if found. That works fine. What i struggling with is i want to find an string in a line and if true look for another string in the very next line, if true, message box both values.

Any ideas

One way

StringArray arr= FileReadAllLines(sample.txt)

While line <= arr.length -1
If(arr(line).Contains(“xyz”) AND arr(line+1).Contains("xyz))

MessageBox— arr(line) + arr(line+1)

Line = Line +1

Do I do this via the “Invoke power shell”?

Okay i have managed to build it but i get the following:

Main has thrown an exception

Message: Index was out of range. Check that the collection has values and the index is less than the size of the collection.

Source: If

Exception Type: IndexOutOfRangeException


While line <= arr.length -2

Perfect. Thx it worked.

Okay after some testing this did not work. If there is more than 2 lines in the text file it gets stuck in the loop.

Share the screenshot of your workflow, are you incrementing the counter and is the counter outside if condition (inside while).

Use writeline to see which line robot is working on.

Okay it was my mistake. I had the increment in the IF and not the While. Here is the working flow.