码迷,mamicode.com
首页 > Windows程序 > 详细

C# GetValueList 获得字符串中开始和结束字符串中间得值列表

时间:2017-05-27 17:15:18      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:uri   value   options   content   c#   mat   collect   foreach   获取   

        /// <summary>
        /// 获得字符串中开始和结束字符串中间得值列表
        /// </summary>
        /// <param name="styleContent">样式内容</param>
        /// <returns></returns>
        private MatchCollection GetValueList(string str, string s, string e)
        {
            return Regex.Matches(str, "(?<=(" + s + "))[.\\s\\S]*?(?=(" + e + "))", RegexOptions.IgnoreCase);
        }

用法

            MatchCollection HrefList = this.GetValueList(listHtml, ListHrefBegin, ListHrefEnd);
            foreach (Match match in HrefList)//循环获取
            {
                if (match.Value.StartsWith("/"))
                    list += "http://" + uri.Host + match.Value + "\r\n";
                else
                    list += match.Value + "\r\n";
            }

  

C# GetValueList 获得字符串中开始和结束字符串中间得值列表

标签:uri   value   options   content   c#   mat   collect   foreach   获取   

原文地址:http://www.cnblogs.com/wxbug/p/6913392.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!