using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var pattern = "^{(?:(?[^{}]+)|(?{)|(?<-o>}))*(?(o)(?!))}$"; var result = Regex.Matches("{a{bb{ccc{dd}}}}", pattern) .Cast().Select(p => p.Groups["c"].Captures) .ToList(); foreach (var coll in result) foreach (var v in coll) Console.WriteLine(v); } }