using System.Text.RegularExpressions;
public static void Main()
var RemoveWords = new[] { "ABC", "DEF" };
var testStrings = new[] {
"ABC XYZ ABC DEF A1B2 ABC",
var removeRegex = new Regex(@"\b(?:" + string.Join("|", RemoveWords) + @")\b", RegexOptions.IgnoreCase);
var alpha = @"\b[a-z]+\b";
var alnum = @"\b[a-z0-9]+\b";
var matchRegex = new Regex(string.Format(@"{0}.*{1}|{1}.*{0}", alpha, alnum), RegexOptions.IgnoreCase);
foreach (var s in testStrings)
var ok = matchRegex.Match(removeRegex.Replace(s, "")).Success;
Console.WriteLine("{0}:\t{1}", ok ? "OK" : "Failed", s);