using System;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
public class Test
{
public static void Main()
{
var keep = "[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*";
var rx = string.Format("^(?:(?<keep>{0})\"{0}\")+(?<keep>{0})$", keep);
var s = @"Test + ""Hello"" + ""Good\""more"" + \""Escape\""This\""Test\"" + ""f""";
var matches = Regex.Matches(s, rx)
.Cast<Match>()
.SelectMany(m => m.Groups["keep"].Captures.Cast<Capture>().Select(p => p.Value).ToArray())
.ToList();
Console.WriteLine(string.Join("", matches));
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLklPOwp1c2luZyBTeXN0ZW0uVGV4dC5SZWd1bGFyRXhwcmVzc2lvbnM7CgpwdWJsaWMgY2xhc3MgVGVzdAp7CglwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpCgl7CgkJdmFyIGtlZXAgPSAiW15cIlxcXFxdKig/OlxcXFwuW15cIlxcXFxdKikqIjsKCQl2YXIgcnggPSBzdHJpbmcuRm9ybWF0KCJeKD86KD88a2VlcD57MH0pXCJ7MH1cIikrKD88a2VlcD57MH0pJCIsIGtlZXApOwoJCXZhciBzID0gQCJUZXN0ICsgIiJIZWxsbyIiICsgIiJHb29kXCIibW9yZSIiICsgXCIiRXNjYXBlXCIiVGhpc1wiIlRlc3RcIiIgKyAiImYiIiI7CiAgICAgICAgdmFyIG1hdGNoZXMgPSBSZWdleC5NYXRjaGVzKHMsIHJ4KQogICAgICAgIAkuQ2FzdDxNYXRjaD4oKQogICAgICAgIAkuU2VsZWN0TWFueShtID0+IG0uR3JvdXBzWyJrZWVwIl0uQ2FwdHVyZXMuQ2FzdDxDYXB0dXJlPigpLlNlbGVjdChwID0+IHAuVmFsdWUpLlRvQXJyYXkoKSkKICAgICAgICAJLlRvTGlzdCgpOwogICAJCUNvbnNvbGUuV3JpdGVMaW5lKHN0cmluZy5Kb2luKCIiLCBtYXRjaGVzKSk7CgoJfQp9