fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var txt = "[he[[llo][qw[[qwe:]sdsdfsdf [note2]";
  10. var res = Regex.Match(txt, @"^(\[[^]]*])+");
  11. Console.WriteLine(res.Value);
  12. var captures = res.Groups[1].Captures.Cast<Capture>().Select(p => p.Value).ToList();
  13. Console.WriteLine(string.Join(", ", captures));
  14. }
  15. }
Success #stdin #stdout 0.11s 24752KB
stdin
Standard input is empty
stdout
[he[[llo][qw[[qwe:]
[he[[llo], [qw[[qwe:]