Regex.IsMatch Method (String, String, RegexOptions)
using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string[] partNumbers= { "1111-111-1111" };
string pattern = @"^[A-Z0-9]\d{2}[A-Z0-9](-\d{3}){2}[A-Z0-9]$";
foreach (string partNumber in partNumbers)
Console.WriteLine(Regex.IsMatch(partNumber, pattern, RegexOptions.IgnoreCase));
}
}
Related examples in the same category