using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(0[1-9]\d|0\d[1-9]|6[0-57-9]\d|6\d[0-57-9]|[1-57-8]\d\d)-\d{2}-\d{4}$";
string input = @"123-45-6789
123456789
001341343
888-03-1785
888-04-0001
606-04-0001
660-04-0001
666-23-1234
666231234
000-65-1343
000651343
905-31-6375
905316375
888-00-1785
888001785
888-04-0000
888040000
666-00-0000
666-01-4050";
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