using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var exceptions = new[] { "and", "not", "or" }; Console.WriteLine($@"\b(?!(?:{string.Join("|", exceptions)})\b)\w+"); var result = Regex.Replace("This and This not That", $@"\b(?!({string.Join("|", exceptions)})\b)\w+", "\"$&\""); Console.WriteLine(result); } }