Regex Pattern between two characters which has multiple /n

Hello, I want to extract
1a
b
From the below string. I know data manipulation methods, can someone suggest regex pattern for that.
Please note that a and b are just examples , there could be paragraph or line of alphanumeric words instead of a and b, so we should not consider a and b in the string
I want everything starting from 1 (Including 1) before 2

“This is Test Data
1 a
b
2 a
b
3 a
b”

grafik
or Anchored to the 2
grafik

so we would dynamize a and b by variables to be flexible for the other searches
String.Format("{0}(.|\n)*?{1}", var1, var2)

grafik

1 Like

Thank @ppr
With this regex I am able to extract “1(.|\n)*?(?=2 )”
1 a
b

What if I want to extract
2 a
b

and
3 a
b

could be linked to:

maybe the requiremetns are to resharpen

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