网页中有如下代码
<table>
<tr>
<td>
<IMG src="http://localhost/NumberJs/images/128059860327656250.jpg" ><P>123</P>
<IMG src="http://localhost/NumberJs/images/128059860425156250.jpg" ><br>
<IMG src="http://localhost/NumberJs/images/128059860425156251.jpg" >
<a href='#'>其他</a>
</td>
</tr>
</table>
我怎么提取出图片的路径,也就是
http://localhost/NumberJs/images/128059860327656250.jpg
http://localhost/NumberJs/images/128059860425156250.jpg
http://localhost/NumberJs/images/128059860425156251.jpg
这样的格式.具体的代码
先谢谢了,急用!

解决方案 »

  1.   

    (?<=IMG src=).*?(?=>)
      

  2.   

    re.Pattern="\b<img (.*?)src=(.[^\[]*)>\b/g"
    str=re.Replace(str,"$2")
    这个是vb语法
      

  3.   

    "/\< *[img][^\>]*[src] *= *[\"\']{0,1}([^\"\'\ >]*)/i"
      

  4.   

    "/\< *[img][^\>]*[src] *= *[\"\']{0,1}([^\"\'\ >]*)/i"不行,说转义字符无效
      

  5.   

    (?<=IMG src=).*?(?=>)这个方法可以
    但是<IMG height=200 src="/NumberJs/images/128059860327656250.jpg" width=300 border=0><IMG height=200 src="/NumberJs/images/128059860425156250.jpg" width=300 border=0>
    我不想要height,width这样的属性,只要"/NumberJs/images/128059860327656250.jpg"
      

  6.   

    "\b<img (.*?)src=(.[^\[]*)>\b/g"
    已经发过一次拉。
      

  7.   

    re.Pattern="\b<img (.*?)src=(.[^\[]*)>\b/g"
    str=re.Replace(str,"$2")
      

  8.   

    测试数据
    <IMG src="http://localhost/NumberJs/images/128059860327656250.jpga"><P>123</P>
    <IMG src='http://localhost/NumberJs/images/128059860425156250.jpg'><br/>
    正则表达式:(?<=IMG src=(["'])).*?(?=\1\s*>)
    C#:(?<=IMG src=([\"'])).*?(?=\\1\\s*>)
    正则模式:Singleline
    匹配数:2
    匹配结果:
    *******************
    http://localhost/NumberJs/images/128059860327656250.jpga
    *******************
    http://localhost/NumberJs/images/128059860425156250.jpg