fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Collections.Specialized;
  4. class Program
  5. {
  6. static void Main() {
  7. string s1 = @"max,""emily,kate"",john";
  8. var myRegex = new Regex(@"""[^""]*""|(,)");
  9. string replaced = myRegex.Replace(s1, delegate(Match m) {
  10. if (m.Groups[1].Value == "") return m.Value;
  11. else return "SplitHere";
  12. });
  13. string[] splits = Regex.Split(replaced,"SplitHere");
  14. foreach (string split in splits) Console.WriteLine(split);
  15. Console.WriteLine("\nPress Any Key to Exit.");
  16. Console.ReadKey();
  17. } // END Main
  18. } // END Program
Success #stdin #stdout 0.07s 34136KB
stdin
Standard input is empty
stdout
max
"emily,kate"
john

Press Any Key to Exit.