Get number of line from text file where specific word is located

Hi,

Example:

I need get number of line where “abab” word is located.

Please help.

Hi @Paulina_x

Attached is an example
COUNT_MATCHING_LINES.xaml (8.6 KB)

image

split the text within an array strTextVar.Split({Environment.NewLine}, StringSplitOptions.None) - arrLines

assign activity
idx =
arrLines.ToList.FindIndex(Function (x) x.Equals("abab"))

Hi @Paulina_x,

Check this sample,
GetLineNoOfText.xaml (5.3 KB)

HI @Paulina_x

The word you are searching for will always in the starting right?

Try this

  • Read Text file
  • Split new line and store as array
  • Get the line index
    Sample.xaml (5.9 KB)

Hope this helps

Regards
Gokul