How to count how many lines from a specific string?

Hi, I want to get how many lines from a specific string until it counters a blank row. In the text it can go below by pressing enter. I want to count until the below is I’ll add a photo to describe.I want to count how many line between yellow highlihted area. Thanks for all the answers :slight_smile:

1 Like

Hi @demyr

Try below regex:-
Assign:
numberOfLines = System.Text.RegularExpressions.Regex.Matches(textContent, “(?s)your specific string.*?\n\n”).Count

Thanks

Thanks for the quick reply I’ll try it and I’ll keep you updated :slight_smile:

@demyr

I believe this is what you need to use…use in assign requiredvalue is integer type

requiredvalue = System.Text.RegularExpressions.Regex.Matches(System.Text.RegularExpressions.Regex.Match(yourstring,"(?<=your string)[\s\S]*(?=\r?\n{2,})",RegexOptions.None).Value,"\r?\n",RegexOptions.None).Count

And a 1 if you are getting the count less by 1

Cheers