Regular Expression Match variable multiple lines? [duplicate]

Lets say I have the following text and I want to extract the text between "Start of numbers" and "End of numbers" there are dynamic amount of lines and the only thing which changes in the numbers in them eg: first, second, etc. Each file I'll be extracting data from has different amount of lines between between "Start of numbers" and "End of numbers". How can I write a regex to match the content between "Start of numbers" and "End of numbers" without knowing how many lines will be in the file between Start of numbers" and "End of numbers"?

Regards!

This is the first line This is the second line

Start of numbers

This is the first line
This is the second line
This is the third line
This is the ...... line
This is the ninth line

End of numbers

You should use the SingleLine mode which tells your C# regular expression that . matches any character (not any character except \n).

var regex = new Regex("Start of numbers(.*)End of numbers",
                  RegexOptions.IgnoreCase | RegexOptions.Singleline);

You should be able to match multi-line strings without issue. Just remember to add the right characters in (\n for new lines).

string pattern = "Start of numbers(.|\n)*End of numbers";
Match m = Regex.Matches(input, pattern);

This is easier if you can think of your string with the hidden characters.

Start of numbers\n\nThis is the first line\nThis is the second line\n ...