using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^([a-zA-z]{3})(\d{4})(?:\d{2})?(_00)([0-7])(.*)$";
string input = @"HTH0919_001-werelwkre;lkj
HTH0919_007_dgfsdfs
HTH0919_008
HTH0919_009
HtH0919_010
HTH0919_097
HTH0919_098
HTH0919_099
HTH0919_100
HTH0919_111
HTH0919_101
HTH0919_899
HTH123456_020
^([a-zA-z]{3})(\d{4})(?:\d{2})?(_00)([0-7])(.*)$
^([a-zA-z]{3})(\d{4})(?:\d{2})?(_0)(?!98|99)(08|09|[1-9][0-9])(.*)$
^([a-zA-z]{3})(\d{4})(?:\d{2})?_(098|099|[1-9][0-9][0-9])(.*)$";
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