日期:2014-05-17  浏览次数:21050 次

asp去代码
大家好,请问有这么一组代码:
  &nbsp;&nbsp; <img   src= "images/1.gif "   height= "25 "   width= "25 "> &nbsp;&nbsp;大家好,能回答我的问题吗?&nbsp;&nbsp;
我想取出
<img   src= "images/1.gif "   height= "25 "   width= "25 ">
,它前面和后边的是动态的,
请问怎么实现

------解决方案--------------------
<img src= "images/1.gif " height= "25 " width= "25 "> 是固定的话:
r.pattern = " <img src= " "images\/1.gif " " height= " "25 " " width= " "25 " "> "

如果不固定,但字符串中只出现一次IMG,可以这样:
r.pattern = " <img[\s|\S]*?> "
------解决方案--------------------
s = "&nbsp;&nbsp; <img src= " "images/1.gif " " height= " "25 " " width= " "25 " "> &nbsp;&nbsp;大家好,能回答我的问题吗?&nbsp;&nbsp; "
Set regEx = New RegExp
regEx.Pattern = "( <img (.+)> )? "
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(s)
For Each Match in Matches
Response.Write Server.HTMLEncode(Match.SubMatches(0))
Next