JSP正则表达式的问题

655 2005-01-27 06:13:29
希望向一段html代码中的每个img标签中分别加入两个调用JS的鼠标事件,asp中是这样做的

<%
Dim re, strMatches, strMatch, tmpStr1, tmpStr2
Set re=new RegExp
re.IgnoreCase =True
re.Global=True

re.Pattern="\[img\](.*?)\[\/img\]"
Set strMatches=re.Execute(strContent)
For Each strMatch In strMatches
tmpStr1=CheckLinkStr(strMatch.SubMatches(0))
strContent=Replace(strContent,strMatch.Value,"<img src="""&tmpStr1&""" border=""0"" onload=""javascript:DrawImage(this);"" alt=""按此在新窗口打开图片"" onmouseover=""this.style.cursor='hand';"" onclick=""window.open(this.src);"" />")
Next
Set strMatches=Nothing

re.Pattern="\[img=(left|right|center|absmiddle)\](.*?)\[\/img\]"
Set strMatches=re.Execute(strContent)
For Each strMatch In strMatches
tmpStr1=strMatch.SubMatches(0)
tmpStr2=CheckLinkStr(strMatch.SubMatches(1))
strContent=Replace(strContent,strMatch.Value,"<img src="""&tmpStr2&""" align="""&tmpStr1&""" onload=""javascript:DrawImage(this);"" border=""0"" alt=""按此在新窗口打开图片"" onmouseover=""this.style.cursor='hand';"" onclick=""window.open(this.src);"" />")
Next
Set strMatches=Nothing
%>

strContent是从数据库中提出的html内容,THX!!!
...全文
133 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
655 2005-01-28
  • 打赏
  • 举报
回复
自己UP一下!
fjshirley 2005-01-28
  • 打赏
  • 举报
回复
有什么问题可以去www.zhihuigu.com上去问,那有很多一流大虾.......高手如云..专门给人解决问题

有问必答.....各位有时间都可以去看看!!!!!!!!!!!!!!!
wangzhanlili 2005-01-28
  • 打赏
  • 举报
回复
我也不知道 帮顶
以梦为马 2005-01-28
  • 打赏
  • 举报
回复
up

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧