/// <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(ABPS.Aiml.Bot bot, ABPS.Aiml.Utils.SettingsDictionary dictionary, string target) { string marker = ApplySubstitutions.getMarker(5); string result = target; foreach (string pattern in dictionary.SettingNames) { string p2 = ApplySubstitutions.makeRegexSafe(pattern); //string match = "\\b"[email protected]().Replace(" ","\\s*")+"\\b"; string match = "\\b" + p2.TrimEnd().TrimStart() + "\\b"; string replacement = marker + dictionary.grabSetting(pattern).Trim() + marker; result = Regex.Replace(result, match, replacement, RegexOptions.IgnoreCase); } return(result.Replace(marker, "")); }
protected override string ProcessChange() { return(ApplySubstitutions.Substitute(this.bot, this.bot.Substitutions, this.inputString)); }