首页 > Windows开发 > 详细

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

时间:2017-05-27 16:52:10      阅读:327      评论:0      收藏:0      [点我收藏+]
        /// <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 获得字符串中开始和结束字符串中间得值列表

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!