需求:
1、尽可能多的匹配出网页里面的图片地址。
2、要求分组。
如:<img scr="<url>">
结果为
match.Groups["url"]

解决方案 »

  1.   

    @"(?si)<img\b.*?src\s*=\s*""(?<url>[^""]+)"""
      

  2.   

    http://topic.csdn.net/u/20080420/19/F36FB7C0-B8A5-4D67-837C-9DC3A96907B8.html
      

  3.   

    @"(?si)<img\b.*?src\s*=\s*""(?<url>[^""]+)"""
    typeof  我试了一下你的
    还可以 
    不过有的还是匹配不到
      

  4.   

    <img .*?src=(""|')?(?<url>.*?)(""|'| |>)//try
      

  5.   


    "(?is)<img.*?src=[\"'](?<url>[^\"'\\s]+)"
      

  6.   

    typeof的:
    @"(?si)<img\b.*?src\s*=\s*""(?<url>[^""]+)"""
    匹配不带alt挺管用wackyboy的:
    "(?is)<img.*?src=[\"'](?<url>[^\"'\\s]+)"
    匹配带alt的挺管用有没有一个通用的  。
      

  7.   

    wackyboy的:
    匹配成功的如 : http://www.tupian.com/sort/6_3.htm
    匹配不成功的如: http://www.asiacool.com/cng/ai_jing/typeof的正好相反
      

  8.   


    "<img[^>]*src=\"(?<url>[^\"]*)[^>]*>"
      

  9.   


                string str = "<p> <img alt=\"Cuba\" width=\"400\" height=\"300\" align=\"textTop\" src=\"http://www.tupian.com/sort/6_3.htm \" /> </p> "
    + "<p> <img alt=\"Cba\" width=\"400\" height=\"300\" align=\"textTop\" src=\"http://www.asiacool.com/cng/ai_jing/\" /> </p>";
                //ListNode ln = new ListNode();
                Regex re = new Regex("(?is)<img.*?src=[\"'](?<url>[^\"'\\s]+)");
                foreach (Match m in re.Matches(str))
                {
                    Console.WriteLine(m.Value);
                }我的这样是可以的
    两种情况都可以匹配
    不知道楼主所说的情况是怎么产生的
      

  10.   

    <img[\s]*src="(?<url>[^>]*)>
      

  11.   

    wackyboy
    你去匹配一下http://www.asiacool.com/jpg/Mai_Kuraki/这个页面
      

  12.   


    Regex re = new Regex("(?is)<img.*?src=[\"']?(?<url>[^\"'\\s>]+)");你那个网站够水平!!
      

  13.   

    http://sports.joy.cn/tg/03/26/www/index.shtml
      

  14.   

    wackyboy
    Regex re = new Regex("(?is)<img.*?src=[\"']?(?<url>[^\"'\\s>]+)");匹配其他网站又不行了  
      

  15.   


    Regex re = new Regex("(?is)<img.*?src=[\"']?(?<url>[^\"'\\s>]+)"); 
    // ?的问题??
    希望有一些源字符串
      

  16.   

    算了  结贴吧
      各位辛苦了
    特别是wackyboy 
    如果你以后写出一个比上面更好的表达式,记得帮我留下
    呵呵
      

  17.   

    Regex clearString = new Regex("<img.*?src=\"(.+?)\"", RegexOptions.IgnoreCase | RegexOptions.Compiled);