using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.IO; using System.Text; public class Test { public static void Main() { string pattern = @"\A(?:\.(?[A-Za-z]+)\((?[^()]*)\))+\z"; var strings = new List() { ".Foo().Bar(20).Baz(Hello)", ".Foo().Bar(30)k.Baz(Hi)hgjfvg", ".Foo(test).Bar(40).Baz(Bye)" }; foreach (var input in strings) { foreach (Match m in Regex.Matches(input, pattern)) { m.Groups["exName"] .Captures.Select(c => c.Value) .Zip( m.Groups["exVal"].Captures.Select(c => c.Value), (exName, exVal) => exName + " -> " + exVal ).ToList() .ForEach(s => Console.WriteLine(s)); Console.WriteLine("---------------"); } } } }