public DynamicRegexArticleComparer(string comparator, RegexOptions options) { Comparator = comparator; Options = (options & ~RegexOptions.Compiled); // Create a regex to try it out. Throws an exception if there's a regex error new Regex(Tools.ApplyKeyWords("a", comparator), options); }
/// <summary> /// Returns true if the article should be skipped based on the text it does or doesn't contain /// </summary> /// <param name="FindText">The text to find</param> /// <param name="regEx">True if FindText contains a regular expression</param> /// <param name="caseSensitive">True if the search should be case sensitive</param> /// <param name="DoesContain">True if the article should be skipped if it contains the text, false if it should be skipped if it does *not* contain the text</param> /// <returns>A boolean value indicating whether or not the article should be skipped</returns> public bool SkipIfContains(string FindText, bool regEx, bool caseSensitive, bool DoesContain) { if (FindText.Length > 0) { RegexOptions regexOptions = (caseSensitive) ? RegexOptions.None : RegexOptions.IgnoreCase; FindText = Tools.ApplyKeyWords(Name, FindText); if (!regEx) { FindText = Regex.Escape(FindText); } if (Regex.IsMatch(OriginalArticleText, FindText, regexOptions)) { return(DoesContain); } return(!DoesContain); } return(false); }
/// <summary> /// Returns true if the article should be skipped based on the text it does or doesn't contain /// </summary> /// <param name="FindText">The text to find</param> /// <param name="Regexe">True if FindText contains a regular expression</param> /// <param name="caseSensitive">True if the search should be case sensitive</param> /// <param name="DoesContain">True if the article should be skipped if it contains the text, false if it should be skipped if it does *not* contain the text</param> /// <returns>A boolean value indicating whether or not the article should be skipped</returns> public bool SkipIfContains(string FindText, bool RegEx, bool CaseSensitive, bool DoesContain) { if (FindText.Length > 0) { RegexOptions regexOptions; if (CaseSensitive) { regexOptions = RegexOptions.None; } else { regexOptions = RegexOptions.IgnoreCase; } FindText = Tools.ApplyKeyWords(this.Name, FindText); if (!RegEx) { FindText = Regex.Escape(FindText); } if (Regex.IsMatch(this.OriginalArticleText, FindText, regexOptions)) { return(DoesContain); } else { return(!DoesContain); } } else { return(false); } }
public bool Matches(Article article) { return(article.ArticleText.IndexOf(Tools.ApplyKeyWords(article.Name, Comparator), StringComparison.CurrentCultureIgnoreCase) >= 0); // or should that be OrdinalIgnoreCase? }
public bool Matches(Article article) { return(article.ArticleText.Contains(Tools.ApplyKeyWords(article.Name, Comparator))); }
public bool Matches(Article article) { string text = Tools.ConvertFromLocalLineEndings(article.ArticleText); return(text.IndexOf(Tools.ApplyKeyWords(article.Name, Comparator), StringComparison.CurrentCultureIgnoreCase) >= 0); }
public bool Matches(Article article) { string text = Tools.ConvertFromLocalLineEndings(article.ArticleText); return(text.Contains(Tools.ApplyKeyWords(article.Name, Comparator))); }
public bool Matches(Article article) { string text = Tools.ConvertFromLocalLineEndings(article.ArticleText); return(Regex.IsMatch(text, Tools.ApplyKeyWords(article.Name, Comparator), Options)); }
public bool Matches(Article article) { return(Regex.IsMatch(article.ArticleText, Tools.ApplyKeyWords(article.Name, Comparator), Options)); }