码迷,mamicode.com
首页 > 其他好文 > 详细

正则表达式全局匹配网址

时间:2015-11-09 18:33:41      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:

static void Main(string[] args)
        {
            string atxet = @"<h3 style=‘color: blue‘>
 <img src=‘http://sp-dev01/KBC/KMS/KnowledgeEditImage/searchForKM20151109041139.jpg‘ />32323<img alt=‘laugh‘ height=‘20‘ src=‘http://sp-dev01/_layouts/portal/CKEditor/plugins/smiley/images/teethsmile.gif‘ title=‘laugh‘ width=‘20‘ /><img src=‘http://sp-dev01/KBC/KMS/KnowledgeEditImage/searchForKM20151109041139.jpg‘ /></h3>
<hr /><p> <img src=‘http://sp-dev01/KBC/KMS/KnowledgeEditImage/searchForKM201511 09041139.jpg‘ />323343434</p>";

            Regex reg = new Regex(@"http://([a-zA-Z0-9-/ _]+)+.(gif|png|jpg)", RegexOptions.IgnoreCase);
            MatchCollection matchs = reg.Matches(atxet);
            foreach (Match item in matchs)
            {
                if (item.Success)
                {
                    Console.WriteLine(item.Value); //这里就是匹配到的项 
                }
            }
            Console.Read();
        }

 

正则表达式全局匹配网址

标签:

原文地址:http://www.cnblogs.com/ChineseMoonGod/p/4950601.html

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