using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"DE\s+(3[01]|[12]\d|[1-9])\s+DE";
string input = @"DE 1 DE
DE 2 DE
DE 3 DE
DE 4 DE
DE 5 DE
DE 6 DE
DE 7 DE
DE 8 DE
DE 9 DE
DE 10 DE
DE 11 DE
DE 12 DE
DE 13 DE
DE 14 DE
DE 15 DE
DE 16 DE
DE 17 DE
DE 18 DE
DE 19 DE
DE 20 DE
DE 21 DE
DE 22 DE
DE 23 DE
DE 24 DE
DE 25 DE
DE 26 DE
DE 27 DE
DE 28 DE
DE 29 DE
DE 30 DE
DE 31 DE
DE 32 DE
DE 0 DE
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx