using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(02|03|04|06|08|09|072|074|076|077|078|079|050|051|052|053|054|055|056|058|059)((?:(?![1,0]{1}))\d{7})$";
string input = @"Valid:
022345677
032345677
042345677
062345677
082345677
092345677
0722345677
022345677
0742345677
0762345677
0742345677
0762345677
0772345677
0782345677
0792345677
0502345677
0512345677
0522345677
0532345677
0542345677
0552345677
0562345677
0582345677
0592345677
NotValid :
021345677
030345677
142345677
362345677
282345677
492345677
5722345677
622345677
7742345677
8762345677
9742345677
";
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