fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var s = "\"first \\\"value\\\\\\\\\", \"second, value\", \"third value\"";
  10. Console.WriteLine(s);
  11. var results = Regex.Matches(s, @"(?<!\\)(?:\\{2})*""([^\\""]*(?:\\.[^""\\]*)*)""")
  12. .Cast<Match>()
  13. .Select(x => x.Groups[1].Value);
  14. Console.WriteLine($"'{string.Join("', '", results)}'");
  15.  
  16.  
  17. }
  18. }
Success #stdin #stdout 0.08s 20568KB
stdin
Standard input is empty
stdout
"first \"value\\\\", "second, value", "third value"
'first \"value\\\\', 'second, value', 'third value'