I am trying to match the contents between BEGIN and END into a capture group called numbers from this string note:
string note = @"BEGIN
781-222-3311
9789001122
7817770000 to 7817770010
END";
The variable I am putting the matched group value into is numbers. What I am using to match the string is the following:
string numbers = "";
Regex numberEncapsulationRegex = new Regex(@"begin\n(?<numbers>.+)\nend", RegexOptions.IgnoreCase);
Match numberCatch = numberEncapsulationRegex.Match(note);
if (numberCatch.Success)
{
Console.WriteLine("SUCCESS: \n");
numbers += numberCatch.Groups["numbers"].Value;
}
I have tried using RegexOptions.Multiline along with RegexOptions.IgnoreCase, and have also tried using:
(?i:begin)\n(?<numbers\>.+)\n(?i:end)
(?i:begin)(\n?<numbers>.+\n)(?i:end)
(?<=BEGIN)(.*)(?=END)
Cannot get this to work. Thank you for reading and for helping, if willing.