zoukankan      html  css  js  c++  java
  • 正则表达式全局匹配网址

    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();
            }
  • 相关阅读:
    实验四
    实验三
    实验二
    实验一
    6
    5
    4
    3
    shiyan2
    实验1
  • 原文地址:https://www.cnblogs.com/ChineseMoonGod/p/4950601.html
Copyright © 2011-2022 走看看