Info We see how the RegexOptions.Multiline argument was passed as the third parameter to the Regex.Matches static method.
// Input string.
const string example = @"This string
has two lines";
// Get a collection of matches with the Multiline option.
MatchCollection matches = Regex.Matches(example, "^(.+)$", RegexOptions.Multiline);
foreach (Match match in matches)
// Loop through captures.
foreach (Capture capture in match.Captures)
// Display them.
Console.WriteLine("--" + capture.Value);
--has two lines
Notes, RegexOptions. We can use an enumerated constant with Regex methods. There are other RegexOptions you can consider. For complicate problems, a RegexOptions enum is often needed.