当前位置: 代码迷 >> ASP >> asp去代码解决思路
  详细解决方案

asp去代码解决思路

热度:65   发布时间:2012-04-10 21:03:56.0
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
  相关解决方案