<IMG  onload=\ "if(this.width&gt;screen.width*0.7)   {this.resized=true;   this.width=screen.width*0.7;   this.alt=点击查看大图;   this.title=点击查看大图;}\ " 
src= \"http://images18.567.com/1002/1192961814_0.36420200.jpg \"   border=0   name=mms_img> 
<IMG src= \"http://images18.567.com/1402/1192961814_0.36420333.jpg \" border=0>如何取img标签中src=""的内容,正则如何写
本人认为首先应该匹配<IMG ... src=""> 然后再从中取出src=""的内容.
哪位大侠指教一下

解决方案 »

  1.   

    参考如下代码
    string s = textBox1.Text;
    foreach (Match vMatch in Regex.Matches(s,
        @"<img[^>]*\s*src\s*=\s*""(?<src>[^>^""]*)""[^>]*>", RegexOptions.IgnoreCase))
    {
        Console.WriteLine(vMatch.Result("${src}"));
    }
    输入内容
    <IMG onload="if(this.width&gt;screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt=点击查看大图; this.title=点击查看大图;}" 
    src="http://images18.567.com/1002/1192961814_0.36420200.jpg" border=0 name=mms_img> 
    <IMG src="http://images18.567.com/1402/1192961814_0.36420333.jpg" border=0> 输出结果
    [code=BatchFile]http://images18.567.com/1002/1192961814_0.36420200.jpg
    http://images18.567.com/1402/1192961814_0.36420333.jpg[/code]
      

  2.   

    楼上正解.
    此题不接分.只为学习LS的敬业精神
    照应楼主的内容写了一个..,
    希望楼主尽早接贴..string s =内容 ;
    foreach (Match vMatch in Regex.Matches(s,
        @"<IMG\s+.*?\s+src=\s+\\\s+"(?<src>.*?)\s.*?>", RegexOptions.IgnoreCase))
    {
        Console.WriteLine(vMatch.Result("${src}"));
    }