首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

asp去代码解决思路

2012-04-10 
asp去代码大家好,请问有这么一组代码:imgsrc images/1.gif height 25 width 25 大家好,能回答

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

热点排行