测试下这个你就知道了。。<script type="text/javascript">
var FCKRegexLib = {};
FCKRegexLib.ProtectUrlsImgApo = /(<img\s.*?src=)("|')(.+?)\2/gi ;
FCKRegexLib.ProtectUrlsImgNoApo = /(<img\s.*?src=)([^"'][^ >]+)/gi ;var A = "<img src='wc.gif' \/>\n<img src=wc.gif \/>";
A=A.replace(FCKRegexLib.ProtectUrlsImgApo,'$1$2$3$2 _fcksavedurl=$2$3$2');A=A.replace(FCKRegexLib.ProtectUrlsImgNoApo,'$1$2 _fcksavedurl="$2"');
alert(A);
</script>

解决方案 »

  1.   

    它只是把所有链接后面复制一个相同的链接,就相当于加了一个属性叫。_fcksavedurl内容与src属性内容相同。
      

  2.   

    不过一个式子也可以实现同样的功能。。
    <script type="text/javascript">
    var p = /(<img\s.*?src=)(?:("|')(.+?)\2|([^ >]+))/gi;
    var A = "<img src='wc.gif' \/>\n<img src=wc.gif \/>";
    A = A.replace(p, "$1\"$3$4\" _fcksavedurl=\"$3$4\"");
    alert(A);
    </script>
      

  3.   

    //正则替换FCKRegexLib.ProtectUrlsImgApo = /(<img\s.*?src=)("|')(.+?)\2/gi ;
    //设置两个正则
    FCKRegexLib.ProtectUrlsImgNoApo = /(<img\s.*?src=)([^"'][^ >]+)/gi ;//替换
    把<img src="除回车等任意字符"
    换成
    原字符不变_fcksavedurl="或者'原来的SRC里的内容"或者'
    A=A.replace(FCKRegexLib.ProtectUrlsImgApo,'$1$2$3$2 _fcksavedurl=$2$3$2');//第二个和第一个实现相同功能
    A=A.replace(FCKRegexLib.ProtectUrlsImgNoApo,'$1$2 _fcksavedurl="$2"');
      

  4.   

    /(<img\s.*?src=)("|')(.+?)\2/gi  我测试过了,就是你说的那样
    /(<img\s.*?src=)([^"'][^ >]+)/gi 这个出了问题例如 <img src="http://aaa.jpg" onload="if(aaa>0)...."> 这样有脚本的时候,他会先判断
    并从aaa>0 的 >前添加连接,如何能够控制这种情况发生?
      

  5.   

    <script type="text/javascript">
    var p = /(<img\s.*?src=)(?:("|')(.+?)\2|([^ >]+))/gi;
    var A = "<img src='wc.gif' \/>\n<img src=wc.gif \/>\n<img src='http://aaa.jpg' onload='if(aaa>0)....'>";
    A = A.replace(p, "$1\"$3$4\" _fcksavedurl=\"$3$4\"");
    alert(A);
    </script>
    有什么问题么?
      

  6.   

    即使是FCK的那个reg也不会出现你说的问题的。。
    它不是匹配完整的img标记,只是匹配到内容"?
    然后结束并从后面加那个东西。。
      

  7.   

    哈,又是这个问题。
    今天muxrwc大哥怎么没飘过来?
    看看这个
    http://community.csdn.net/Expert/TopicView.asp?id=5395523
      

  8.   

    就是fck那个<IMG style=\"WIDTH: 356px; HEIGHT: 315px\" height=517 alt=查看更多精彩图片 src=\"http://photo5.hexun.com/p/2007/0414/89779/b_7362DB2E1960C63AF66A465D2F4122C1.jpg\" width=500 onload=\"var image=new Image();image.src=this.src;if(image.width>0 &amp;&amp; image.height>0){if(image.width>=510){this.width=510;this.height=image.height*510/image.width;}}\" border=0>就有问题,您帮忙看下,该如何修改正则表达式!
      

  9.   

    <script type="text/javascript">
    var FCKRegexLib = {};
    FCKRegexLib.ProtectUrlsImgApo = /(<img\s.*?src=)("|')(.+?)\2/gi ;
    FCKRegexLib.ProtectUrlsImgNoApo = /(<img\s.*?src=)([^"'][^ >]+)/gi ;var A = '<IMG style=\"WIDTH: 356px; HEIGHT: 315px\" height=517 alt=?看更多精彩?片 src=\"http://photo5.hexun.com/p/2007/0414/89779/b_7362DB2E1960C63AF66A465D2F4122C1.jpg\" width=500 onload=\"var image=new Image();image.src=this.src;if(image.width>0 &amp;&amp; image.height>0){if(image.width>=510){this.width=510;this.height=image.height*510/image.width;}}\" border=0>';
    //var A="<img src='wc.gif' \/>\n<img src=wc.gif \/>";
    A=A.replace(FCKRegexLib.ProtectUrlsImgApo,'$1$2$3$2 _fcksavedurl=$2$3$2');A=A.replace(FCKRegexLib.ProtectUrlsImgNoApo,'$1$2 _fcksavedurl="$2"');
    alert(A);
    </script>没问题呀
      

  10.   

    你说的在标签里含有<的问题,老问题喽
    做个检验,只要别让这个<在引号里就可以了
      

  11.   

    /gg,他这个不涉及到包含>的这个情况。。
    因为式子里。只有没引号的情况下才判断的是[^ >],但是没引号的情况下,地址里是不可能有>的,所以按空格匹配,就可以找到src内容结尾的。。所以当匹配到空格的时候整个式子就完整的匹配完一次了。。这样下次匹配还会从式子开头重新匹配。。这样还会跳过其他属性继续匹配img标记。。所以不会出现他说的情况。。
      

  12.   

    <textarea id="wc">
    <IMG style="WIDTH: 356px; HEIGHT: 315px" height=517 alt=查看更多精彩图片 src="http://photo5.hexun.com/p/2007/0414/89779/b_7362DB2E1960C63AF66A465D2F4122C1.jpg" width=500 onload="var image=new Image();image.src=this.src;if(image.width>0 &amp;&amp; image.height>0){if(image.width>=510){this.width=510;this.height=image.height*510/image.width;}}" border=0>
    </textarea>
    <script type="text/javascript" defer="defer">
    var p = /(<img\s.*?src=)(?:("|')(.+?)\2|([^ >]+))/gi;
    var A = document.getElementById("wc").value;
    A = A.replace(p, "$1\"$3$4\" _fcksavedurl=\"$3$4\"");
    alert(A);
    </script>
      

  13.   

    "<"符号楼主帖子里没说,短消息里讲的,
    :)不过只是上面的需求确实没有必要判断<
    src就截止了
      

  14.   

    ^o^
    嘿,两个式子实现的时候涉及到一个已经替换掉了,然后属性的内容里有src=的若干种形式。。
    解决方法。。
    <textarea id="wc" style="width:900px;height:500px;">
    <IMG style="WIDTH: 356px; HEIGHT: 315px" height=517 alt=查看更多精彩图片 src="http://photo5.hexun.com/p/2007/0414/89779/b_7362DB2E1960C63AF66A465D2F4122C1.jpg" width=500 onload="var image=new Image();image.src=this.src;if(image.width>0 &amp;&amp; image.height>0){if(image.width>=510){this.width=510;this.height=image.height*510/image.width;}}" border=0>
    <IMG style="WIDTH: 356px; HEIGHT: 315px" height=517 alt=查看更多精彩图片 src=wc border=0>
    <IMG style="WIDTH: 356px; HEIGHT: 315px" height=517 alt=查看更多精彩图片 src=wc BT="var src=window ;this.src='某图片';" border=0>
    </textarea>
    <script type="text/javascript" defer="defer">
    var FCKRegexLib = {};
    FCKRegexLib.ProtectUrlsImgApo= /(<img\s(?:"[^"]*"|'[^']*'|[^>'"])*?src=)("|')(.+?)\2/gi ;
    FCKRegexLib.ProtectUrlsImgNoApo= /(<img\s(?:"[^"]*"|'[^']*'|[^>'"])*?src=)([^"'][^ >]+)/gi ;
    var wc = document.getElementById("wc"), A = wc.value;
    A=A.replace(FCKRegexLib.ProtectUrlsImgApo,'$1$2$3$2 _fcksavedurl=$2$3$2');
    A=A.replace(FCKRegexLib.ProtectUrlsImgNoApo, '$1$2 _fcksavedurl="$2"');
    wc.value = A;
    </script>
      

  15.   

    TO:slowhand(早起的鸟儿有虫吃,那么早起的虫子呢?) 那个式子写错了。。呵,改成这个。。var p = /<(?:"[^"]*"|'[^']*'|[^>'"]*)+>/g;
      

  16.   

    正则里src= 的前面应该是空格
      

  17.   

    to mingxuan3000(铭轩) 现在白痴都喜欢从图片里写JS。。
    比如它这样写的呢?<IMG style="WIDTH: 356px; HEIGHT: 315px" height=517 alt=查看更多精彩图片 src=wc BT="var src=window ;this.src='某图片';" border=0>:Dvar src = ....
    哈哈,前面有空格吧?