/// <summary> /// Static helper that applies replacements from the passed dictionary object to the /// target string /// </summary> /// <param name="bot">The bot for whom this is being processed</param> /// <param name="dictionary">The dictionary containing the substitutions</param> /// <param name="target">the target string to which the substitutions are to be applied</param> /// <returns>The processed string</returns> public static string Substitute(Bot bot, SettingsDictionary dictionary, string target) { string result = MakeCaseInsensitive.TransformInput(target); foreach (string pattern in dictionary.SettingNames) { string p2 = ApplySubstitutions.makeRegexSafe(pattern); //string match = "\\b" + @p2.Trim() + "\\b"; string match = @p2; result = Regex.Replace(result, match, dictionary.GrabSetting(pattern)); } return(result); }
protected override string ProcessChange() { string result = MakeCaseInsensitive.TransformInput(this.inputString); foreach (string pattern in this.Bot.Substitutions.SettingNames) { string p2 = ApplySubstitutions.makeRegexSafe(pattern); //string match = "\\b" + p2.Trim() + "\\b"; string match = @p2; result = Regex.Replace(result, match, this.Bot.Substitutions.GrabSetting(pattern)); } return(MakeCaseInsensitive.TransformInput(result)); }