using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @/
(([0-9]{1,2}|[a-z]{1,3})-([0-9]{2,3}|[a-z]{2,3})-([0-9]{1,2}|[a-z]{1,2}))
/;
string input = @"XX-99-99
2 1965 99-99-XX
3 1973 99-XX-99
4 1978 XX-99-XX
5 1991 XX-XX-99
6 1999 99-XX-XX
7 2005 99-XXX-9
8 2009 9-XXX-99
9 2006 XX-999-X
10 2008 X-999-XX
11 2015 XXX-99-X";
RegexOptions options = RegexOptions.IgnoreCase;
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