using System;
using System.Linq;
using System.Text.RegularExpressions;
public class Test
{
public static void Main()
{
var text="red 1 green 3 blue";
Console.WriteLine(string.Join(";", Regex.Split(text, @"red|green|blue")));
Console.WriteLine(string.Join(";", Regex.Split(text, @"red|green|blue").Where(x => !string.IsNullOrEmpty(x))));
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLlRleHQuUmVndWxhckV4cHJlc3Npb25zOwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCXZhciB0ZXh0PSJyZWQgMSBncmVlbiAzIGJsdWUiOwoJCUNvbnNvbGUuV3JpdGVMaW5lKHN0cmluZy5Kb2luKCI7IiwgUmVnZXguU3BsaXQodGV4dCwgQCJyZWR8Z3JlZW58Ymx1ZSIpKSk7CgkJQ29uc29sZS5Xcml0ZUxpbmUoc3RyaW5nLkpvaW4oIjsiLCBSZWdleC5TcGxpdCh0ZXh0LCBAInJlZHxncmVlbnxibHVlIikuV2hlcmUoeCA9PiAhc3RyaW5nLklzTnVsbE9yRW1wdHkoeCkpKSk7Cgl9Cn0=