码迷,mamicode.com
首页 > Web开发 > 详细

获取一段html代码img表情包含的src路径

时间:2016-08-01 15:17:32      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:

        /// <summary>
        /// 获取所有img里面的src路径
        /// </summary>
        /// <param name="sHtmlText"></param>
        /// <returns></returns>
        public static string[] GetHtmlImageUrlList(string sHtmlText)
        {
            Regex regImg = new Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""‘]?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""‘<>]*)[^<>]*?/?[\s\t\r\n]*>");//img在IE里取出是大写 所以在Ie上面用户img替换成大写 或者html代码转换成小写
            MatchCollection matches = regImg.Matches(sHtmlText);
            int i = 0;
            string[] sUrlList = new string[matches.Count];
            foreach (Match match in matches)
            {
                sUrlList[i++] = match.Groups["imgUrl"].Value;
            }
            return sUrlList;
        }

获取一段html代码img表情包含的src路径

标签:

原文地址:http://www.cnblogs.com/pjh7/p/5725753.html

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