fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var line = "System.Action[Int32,Dictionary[Int32,Int32],Int32]";
  12. var pattern = @"\w+(?:\.\w+)*\[(?:,?(?<res>\w+(?:\[[^][]*])?))*";
  13. var result = Regex.Matches(line, pattern)
  14. .Cast<Match>()
  15. .SelectMany(x => x.Groups["res"].Captures.Cast<Capture>()
  16. .Select(t => t.Value))
  17. .ToList();
  18. foreach (var s in result) // DEMO
  19. Console.WriteLine(s);
  20. }
  21. }
Success #stdin #stdout 0.12s 24720KB
stdin
Standard input is empty
stdout
Int32
Dictionary[Int32,Int32]
Int32