fork download
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var line = "[A] == [B] * 10 - FUNCTION{[C], STRING_EXPRESSION, FUNCTION{[D],[C],[E]}}, FUNCTION{[C], [X]}, 100";
  10. var matches = Regex.Matches(line, @"(?:(?:\{(?>[^{}]+|{(?<n>)|}(?<-n>))*(?(n)(?!))})|[^,])+");
  11. foreach (Match m in matches)
  12. Console.WriteLine(m.Value.Trim());
  13.  
  14. }
  15. }
Success #stdin #stdout 0.08s 21348KB
stdin
Standard input is empty
stdout
[A] == [B] * 10 - FUNCTION{[C], STRING_EXPRESSION, FUNCTION{[D],[C],[E]}}
FUNCTION{[C], [X]}
100