using System.Text.RegularExpressions;
public static void Main()
var simplifiedRegex = "<docnum> - <doctitle> [<revision>].<suffix>";
var fullRegex = "^(?<docnum>\\w+)\\s*-\\s*(?<doctitle>[\\w\\s\\&\\,\\-]*)\\s*\\[(?<revision>\\w+)\\]\\.(?<suffix>\\w+)$";
ValidateRegex(simplifiedRegex);
ValidateRegex(fullRegex);
private static void ValidateRegex(string regexStr) {
Console.WriteLine("Regex string: "+ regexStr);
Regex regex = new Regex(regexStr, RegexOptions.IgnoreCase);
Match match = regex.Match("");
var isMatch = regex.IsMatch("");
Console.WriteLine("isMatch: " + isMatch);
var groupNames = regex.GetGroupNames();
Console.WriteLine("Group name length: " + groupNames.Length);
Console.WriteLine("Group names:");
foreach (var name in groupNames) {