真不争为什么用这个正则不能代换?

clkun 2005-04-01 01:48:44
function s(a)
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="<IMG*SRC(=| )(.[^>]*).algin=(.*)>"
s=re.replace(a,"<IMG SRC=$2 algin=$3> border=0")
msgbox s
end function

b="<IMG onmousewheel=""return bbimg(this)"" style=""CURSOR: pointer""

onclick=window.open(this.src); SRC=""uploadfiles/2005-4/200541132047242.jpg"" onload=""if(this.width >screen.width-500)this.style.width=screen.width-500;"" align=left

border=0>"

s(b)

我要用将上面的b字符串经过函数s转换后,变成<IMG SRC="uploadfiles/2005-4/200541132047242.jpg" align=left border=0>

为什么上面的正则不行,帮忙改一下
...全文
79 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
scoutlin 2005-04-01
  • 打赏
  • 举报
回复
<Script Language=Vbscript>
Dim Regex
Str = "<IMG onmousewheel=""return bbimg(this)"" style=""CURSOR: pointer"" onclick=window.open(this.src); SRC=""uploadfiles/2005-4/200541132047242.jpg"" onload=""if(this.width>screen.width-500)this.style.width=screen.width-500;"" align=left border=0>
"
Set Regex = New Regexp
Regex.Pattern = "<img.*?src=""(.*?)"".*?0>"
Regex.Ignorecase = True
Regex.Global = True
Replacetest = Regex.Replace(Str, "$1")
Set Regex=Nothing
Msgbox Replacetest
</Script>
北京-李大鹏 2005-04-01
  • 打赏
  • 举报
回复
调了半天也没能把vbscript弄出来。呵呵。还是用javascript吧。
<script language="javascript">
var reg = /src=\"(.*)\" (.*) align=(.*) (.*)/i;
b='<IMG onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick=window.open(this.src); SRC="uploadfiles/2005-4/200541132047242.jpg" onload="if(this.width >screen.width-500)this.style.width=screen.width-500;" align=left border=0>';

var arr = reg.exec(b);
var newString = "<img src=" + RegExp.$1 + " align=" + RegExp.$3 + " border=0>";
alert(newString);
</script>
clkun 2005-04-01
  • 打赏
  • 举报
回复
B字符串为:

b="<IMG onmousewheel=""return bbimg(this)"" style=""CURSOR: pointer"" onclick=window.open(this.src); SRC=""uploadfiles/2005-4/200541132047242.jpg"" onload=""if(this.width>screen.width-500)this.style.width=screen.width-500;"" align=left border=0>"
clkun 2005-04-01
  • 打赏
  • 举报
回复
up

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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