using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var line = "System.Action[Int32,Dictionary[Int32,Int32],Int32]"; var pattern = @"\w+(?:\.\w+)*\[(?:,?(?\w+(?:\[[^][]*])?))*"; var result = Regex.Matches(line, pattern) .Cast() .SelectMany(x => x.Groups["res"].Captures.Cast() .Select(t => t.Value)) .ToList(); foreach (var s in result) // DEMO Console.WriteLine(s); } }