using System; using System.IO; using System.Text.RegularExpressions; public class Test { public static void Main() { var line = "[A] == [B] * 10 - FUNCTION([C], STRING_EXPRESSION, FUNCTION([D],[C],[E])), FUNCTION([C], [X]), 100"; var matches = Regex.Matches(line, @"(?:(?:\((?>[^()]+|\((?)|\)(?<-number>))*(?(number)(?!))\))|[^,])+"); foreach (Match m in matches) Console.WriteLine(m.Value.Trim()); } }