fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string pattern = @",(?=[^}]*(?:,|$))";
  9. string input = @"""Key1""=123,""Key2""=""abc"",""key3""={""subkey1""=12,""subkey2""=""cd""},""key4""=456";
  10.  
  11. string[] result = Regex.Split(input, pattern,
  12. RegexOptions.IgnoreCase,
  13. TimeSpan.FromMilliseconds(500));
  14. for (int ctr = 0; ctr < result.Length; ctr++)
  15. {
  16. Console.WriteLine("'{0}'", result[ctr]);
  17.  
  18. }
  19. }
  20. }
Success #stdin #stdout 0.05s 29016KB
stdin
Standard input is empty
stdout
'"Key1"=123'
'"Key2"="abc"'
'"key3"={"subkey1"=12,"subkey2"="cd"}'
'"key4"=456'