using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
public class Test
{
public static void Main()
{
var txt = "[he[[llo][qw[[qwe:]sdsdfsdf [note2]";
var res = Regex.Match(txt, @"^(\[[^]]*])+");
Console.WriteLine(res.Value);
var captures = res.Groups[1].Captures.Cast<Capture>().Select(p => p.Value).ToList();
Console.WriteLine(string.Join(", ", captures));
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uVGV4dC5SZWd1bGFyRXhwcmVzc2lvbnM7CnVzaW5nIFN5c3RlbS5MaW5xOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCXZhciB0eHQgPSAiW2hlW1tsbG9dW3F3W1txd2U6XXNkc2Rmc2RmIFtub3RlMl0iOwoJCXZhciByZXMgPSBSZWdleC5NYXRjaCh0eHQsIEAiXihcW1teXV0qXSkrIik7CgkJQ29uc29sZS5Xcml0ZUxpbmUocmVzLlZhbHVlKTsKCQl2YXIgY2FwdHVyZXMgPSByZXMuR3JvdXBzWzFdLkNhcHR1cmVzLkNhc3Q8Q2FwdHVyZT4oKS5TZWxlY3QocCA9PiBwLlZhbHVlKS5Ub0xpc3QoKTsKCQlDb25zb2xlLldyaXRlTGluZShzdHJpbmcuSm9pbigiLCAiLCBjYXB0dXJlcykpOwoJfQp9