private static string SearchForConnectedSentences(string word, string txt, Regex regex, Rule rule, ILanguage language) { if (!regex.IsMatch(word)) { return(txt); } for (var i = 0; i < UrlAndEmailKeywords.Count; i++) { var webTerm = UrlAndEmailKeywords[i]; if (word.Contains(webTerm)) { return(txt); } } for (var i = 0; i < language.CleanedAbbreviations.Count; i++) { var abbr = language.CleanedAbbreviations[i]; if (word.IndexOf(abbr, StringComparison.OrdinalIgnoreCase) >= 0) { return(txt); } } var newWord = rule.Apply(word); var result = Regex.Replace(txt, $"{Regex.Escape(word)}", newWord); return(result); }