fork(2) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. String input = @"[[Parent1 [[Child 1]],[[Child 2]],[[Child 3]]]] [[Parent2 [[Child 1]],[[Child 2]]]]";
  9. Regex rgx = new Regex(@"(?<parent>Parent\d )|(?!^)\G(?:\[\[(?<child>.*?)]]),?");
  10. foreach (Match m in rgx.Matches(input))
  11. {
  12. Console.WriteLine(m.Groups["parent"].Value);
  13. Console.WriteLine(m.Groups["child"].Value);
  14. }
  15. }
  16. }
Success #stdin #stdout 0.07s 34032KB
stdin
Standard input is empty
stdout
Parent1 


Child 1

Child 2

Child 3
Parent2 


Child 1

Child 2