Find the index of Line Break in a String

I need to know the index (position) of a line break after a specific substring in a string.
Sample String=

I want to know the line break position after “WORD” which should be 14 in this case.
Thanks in advance.

find starter help here:
Demo1.txt (20 Bytes)
RegEx_GetPosition_Of_MatchedResult.xaml (5.3 KB)

Kindly note:

  • the position index is 0 based
  • a linebreak in Windows Environment is: \r\n

thats why a different position index is retrieved.

the solution is based on RegEx: Regex.Match(strText,“(?<=WORD)” + Environment.NewLine)
It is anchoring on the term WORD and looks for the line break after the Anchor


Thanks for your support.

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