正则表达式二者之间匹配的问题

来源:百度知道 编辑:UC知道 时间:2024/04/27 23:03:10
原文:
<img src='http://xxx.gif' border=0 onclick="if(this.width>=690) window.open('http://xxx.gif');" onload="if(this.width>'690')this.width='690';if(this.height>'1024')this.height='1024';">
<img src='http://xxx.gif' border=0 onclick="if(this.width>=690) window.open('http://xxx.gif');" onload="if(this.width>'690')this.width='690';if(this.height>'1024')this.height='1024';">

要改为UBB格式:
[img]http://xxx.gif[/img]
[img]

<img.+?src=['|"]*([^'|"]+?)['|"]*\s([^<>\(\)]*(\(.+?\))*[^<>\(\)]*)*>

[img]$1[/img]

js 测试代码

<script type="text/javascript">

sHTML = '<img src=\'
http://xxx.gif\' border=0 onClick="if(this.width>=690) window.open(\'http://xxx.gif\');" onload="if(this.width>\'690\')this.width=\'690\';if(this.height>\'1024\')this.height=\'1024\';"> <img src=\'http://xxx.gif\' border=0 onClick="if(this.width>=690) window.open(\'http://xxx.