using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Collections.Generic;
public static void Main()
var testValues = new List<string>()
"new List<int>(rthrtht);",
var pattern = @"^new(\s{1,})list(<(.*)>)?\((\d+)?\)(\s+)?;(\s+)?$";
var rgx = new Regex(pattern, RegexOptions.IgnoreCase);
foreach (string testValue in testValues)
Console.WriteLine("{0,5}: {1}", rgx.IsMatch(testValue), testValue);