Argentini.Halide.H3Text.HasWords C# (CSharp) Method

HasWords() public static method

Checks the passed string to see if it has any of the passed words; not case-sensitive.
public static HasWords ( string input ) : MatchCollection
input string The string to check.
return System.Text.RegularExpressions.MatchCollection
        public static MatchCollection HasWords(string input, params string[] hasWords)
        {
            StringBuilder sb = new StringBuilder(hasWords.Length + 50);
            //sb.Append("[");

            foreach (string s in hasWords)
            {
                sb.AppendFormat("({0})|", HttpUtility.HtmlEncode(s.Trim()).Replace("™","™"));
            }

            string pattern = sb.ToString();
            pattern = pattern.TrimEnd('|'); // +"]";

            Regex regEx = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            return regEx.Matches(input);
        }