using System; using System.Text.RegularExpressions; public class Test { public static void Main() { var s = @" asdfasdf asd asd asd ..."; var keyList = new[] { "AccountKey", "PrivateKey", "APIKey", "DefectiveKeyGracefulExpiration" }; var multiplePatternMatching = string.Format("({0})", string.Join("|", keyList)); var rx = string.Format(@"(?si)<([^\s<]*password[^\s<]*|{0})>.*?", multiplePatternMatching); Console.WriteLine(Regex.Replace(s, rx, "<$1>")); } }