Regex, extracting numbered lists (multi lines)

c#, regex

Solution

string input = @"1. This is a text
    where each item can span over multiple lines
    2. that I want to
    extract each seperate
    item from
    3. How can I do that?";
string pattern = @"([\d]+\. )(.*?)(?=([\d]+\.)|($))";
var matches = Regex.Matches(input, pattern, RegexOptions.Singleline);

foreach(Match match in matches)
{
    Console.WriteLine(match.Groups[2].Value);
}

Problem

I got the following text: ``` 1. This is a text where each item can span over multiple lines 2. that I want to extract each seperate item from 3. How can I do that? ``` I tried this regex in refiddle: ``` /([\d]+\.)(.*)/s ``` But I'm unsure of if it's greedy (just returning one item) or if it extracts all items. But when I tried it in C# the regex didn't match anything. What am I doing wrong? Update It's gready but didn't work since `\s` doesn't seem to work in .NET. I can fix the line endings (since they are stripped) myself. But how do I make the regex to not be greedy? Is it possible to say something like Match the digits+dot and then take everything but the next digits+dot?

Original source