using System;
using System.Linq;
using System.Text.RegularExpressions;
public class Test
{
public static void Main()
{
var delim = new string[] {"fox", "lazy"};
var delimGroup = "(?:"+string.Join("|", delim.Select(Regex.Escape))+")";
var pattern = @"\s(?="+delimGroup+")|(?<="+delimGroup+@")\s";
var x = Regex.Split(
"quick brown fox jumps over the lazy dog"
, pattern
);
Console.WriteLine(pattern);
foreach (var s in x)
Console.WriteLine("[{0}]", s);
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLlRleHQuUmVndWxhckV4cHJlc3Npb25zOwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCXZhciBkZWxpbSA9IG5ldyBzdHJpbmdbXSB7ImZveCIsICJsYXp5In07CgkJdmFyIGRlbGltR3JvdXAgPSAiKD86IitzdHJpbmcuSm9pbigifCIsIGRlbGltLlNlbGVjdChSZWdleC5Fc2NhcGUpKSsiKSI7CgkJdmFyIHBhdHRlcm4gPSAgQCJccyg/PSIrZGVsaW1Hcm91cCsiKXwoPzw9IitkZWxpbUdyb3VwK0AiKVxzIjsKCQl2YXIgeCA9IFJlZ2V4LlNwbGl0KAoJCQkicXVpY2sgYnJvd24gZm94IGp1bXBzIG92ZXIgdGhlIGxhenkgZG9nIgoJICAgICwgICBwYXR0ZXJuCgkgICAgKTsKCSAgICBDb25zb2xlLldyaXRlTGluZShwYXR0ZXJuKTsKCSAgICBmb3JlYWNoICh2YXIgcyBpbiB4KQoJICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiW3swfV0iLCBzKTsKCX0KfQ==