fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var input = "One Two \"Three Four\" \"Five \\\"Six\\\"\"";
  12. Console.WriteLine(input);
  13. List<string> matches = Regex.Matches(input, @"(?s)""(?<r>[^""\\]*(?:\\.[^""\\]*)*)""|(?<r>\S+)")
  14. .Cast<Match>()
  15. .Select(x => Regex.Replace(x.Groups["r"].Value, @"\\(.)", "$1"))
  16. .ToList();
  17. foreach (var s in matches)
  18. Console.WriteLine(s);
  19. }
  20. }
Success #stdin #stdout 0.08s 29024KB
stdin
Standard input is empty
stdout
One Two "Three Four" "Five \"Six\""
One
Two
Three Four
Five "Six"