using System.Text.RegularExpressions;

 /// <summary>
        /// 执行正则提取出值
        /// </summary>
        /// <param name="RegexString">正则表达式</param>
        /// <param name="HtmlCode">HtmlCode源代码</param>
        /// <returns>数组</returns>
        public static string[] GetRegValueAarry(string RegexString, string HtmlCode)
        {
            string[] MatchVale = new String[30];//初始化数组
            int i = 0;
            Regex r = new Regex(RegexString);

            for (Match m = r.Match(HtmlCode); m.Success; m = m.NextMatch())
            {
                MatchVale[i] = m.Value.ToString();
                i++;
            }

            return MatchVale;
        }

        /// <summary>
        /// 获取标签内的内容(只取出第一个)
        /// </summary>
        /// <param name="code"></param>
        /// <param name="wordsBegin"></param>
        /// <param name="wordsEnd"></param>
        /// <returns></returns>
        public static string SniffwebCode(string code, string wordsBegin, string wordsEnd)
        {
            string NewsTitle = "";
            Regex regex1 = new Regex("" + wordsBegin + @"(?<content>[\s\S]+?)" + wordsEnd + "", RegexOptions.Compiled | RegexOptions.IgnoreCase);
            for (Match match1 = regex1.Match(code); match1.Success; match1 = match1.NextMatch())
            {
                NewsTitle += match1.Groups["content"].ToString();
                break;
            }
            return NewsTitle;
        }

        // <summary>
        /// 获取标签内的内容并用~连上
        /// </summary>
        /// <param name="code"></param>
        /// <param name="wordsBegin"></param>
        /// <param name="wordsEnd"></param>
        /// <returns></returns>
        public static string SniffwebCodeSplit(string code, string wordsBegin, string wordsEnd)
        {
            string NewsTitle = "";
            Regex regex1 = new Regex("" + wordsBegin + @"(?<content>[\s\S]+?)" + wordsEnd + "", RegexOptions.Compiled | RegexOptions.IgnoreCase);
            for (Match match1 = regex1.Match(code); match1.Success; match1 = match1.NextMatch())
            {
                NewsTitle += match1.Groups["content"].ToString() + "~";
            }
            return NewsTitle;
        }