/^(http|https):\/\/(([A-Z0-9]\w*)(\.[A-Z0-9]\w*)+)(:(\d+))?\/?(([A-Z0-9]\w*)(\.[A-Z0-9]\w*)*)(\??\w+=?[\s\S\w\W]*)?/img
//你原来的正则,把表示行首的^去掉应该就可以了...
//改成下边的
/^(http|https):\/\/(([A-Z0-9]\w*)(\.[A-Z0-9]\w*)+)(:(\d+))?\/?(([A-Z0-9]\w*)(\.[A-Z0-9]\w*)*)(\??\w+=?[\s\S\w\W]*)?/img

解决方案 »

  1.   


    //sorry,刚才还是没给你去掉^,应该是这样
    /(http|https):\/\/(([A-Z0-9]\w*)(\.[A-Z0-9]\w*)+)(:(\d+))?\/?(([A-Z0-9]\w*)(\.[A-Z0-9]\w*)*)(\??\w+=?[\s\S\w\W]*)?/img
      

  2.   

    回“笨笨”<script> 
    String.prototype.Trim= function()
    {
        return this.replace(/(^\s*)|(\s*$)/g, "");
    }function Replace() 

        var ta=document.getElementById("ta");
        
        ta.value = ta.value.Trim().replace(/(http|https):\/\/(([A-Z0-9]\w*)(\.[A-Z0-9]\w*)+)(:(\d+))?\/?(([A-Z0-9]\w*)(\.[A-Z0-9]\w*)*)(\??\w+=?[\s\S\w\W]*)?/img, "$1http://www.yi13.cn/bt/tu.asp?url=$2");
    }</script> <textarea cols="50" rows="20" id="ta"> </textarea> 
    <br/> 
    <input type='button' value='提交' onclick='Replace()'/>
    测试结果:
    输入:
    <P><IMG height=420 alt=按此在新窗口浏览图片 src="http://blog.nnsky.com/photo/20082/37091/200821662038.JPG" width=560 border=0 ="ResizeImage(this,560,1000)"></P>
    <P><IMG height=640 alt=按此在新窗口浏览图片 src="http://blog.nnsky.com/photo/20082/37091/200821679321.JPG" width=480 onload=ResizeImage(this,560,1000) border=0></P>
    <P>&gt;</P>提交后输出:(多了个HTTP)
    <P><IMG height=420 alt=按此在新窗口浏览图片 src="httphttp://www.yi13.cn/bt/tu.asp?url=blog.nnsky.com/20082/37091/200821662038.JPG" width=560 border=0 ="ResizeImage(this,560,1000)"></P>
    <P><IMG height=640 alt=按此在新窗口浏览图片 src="httphttp://www.yi13.cn/bt/tu.asp?url=blog.nnsky.com/20082/37091/200821679321.JPG" width=480 onload=ResizeImage(this,560,1000) border=0></P>
    <P>&gt;</P>
    当输入已经含有http://www.yi13.cn/bt/tu.asp?的时候
    <P><IMG height=420 alt=按此在新窗口浏览图片 src="http://www.yi13.cn/bt/tu.asp?url=blog.nnsky.com/20082/37091/200821662038.JPG" width=560 border=0 ="ResizeImage(this,560,1000)"></P>
    <P><IMG height=640 alt=按此在新窗口浏览图片 src="http://www.yi13.cn/bt/tu.asp?url=blog.nnsky.com/20082/37091/200821679321.JPG" width=480 onload=ResizeImage(this,560,1000) border=0></P>
    <P>&gt;</P>输出:<P><IMG height=420 alt=按此在新窗口浏览图片 src="httphttp://www.yi13.cn/bt/tu.asp?url=www.yi13.cn/tu.asp?url=blog.nnsky.com/20082/37091/200821662038.JPG" width=560 border=0 ="ResizeImage(this,560,1000)"></P>
    <P><IMG height=640 alt=按此在新窗口浏览图片 src="httphttp://www.yi13.cn/bt/tu.asp?url=www.yi13.cn/tu.asp?url=blog.nnsky.com/20082/37091/200821679321.JPG" width=480 onload=ResizeImage(this,560,1000) border=0></P>
    <P>&gt;</P>
    这个条件没用满足
    如果图片地址已经加上:http://www.yi3.cn/tu.asp?url=       
    则就不用再加上:http://www.yi3.cn/tu.asp?url=  

      

  3.   


    <script type="text/ecmascript"> 
    String.prototype.Trim= function()
    {
        return this.replace(/^[\s ]*|[\s ]*$/g, "");
    }function Replace()  { 
        var ta = document.getElementById("ta");
    var reg = /(<img(?:"[^"]*"|'[^']*'|[^"'>])+src=)(?!["']?http:\/\/www\.yi13\.cn\/)(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))((?:"[^"]*"|'[^']*'|[^"'>])*>)/ig;
        //"
    alert("start");
        ta.value = ta.value.Trim().replace(reg, "$1\"http://www.yi13.cn/bt/tu.asp?url=$2$3$4\"$5");
    }
    </script>
    <textarea cols="136" rows="30" id="ta">
    <P><IMG src="http://www.yi13.cn/bt/UpFile/UpAttachment/2008-1/2008111225715.jpg"></P>
    <P><IMG src="http://www.163.com/2008111225715.jpg"></P>
    <P><IMG height=640 alt=按此在新窗口浏览图片 src="http://blog.nnsky.com/photo/20082/37091/200821679321.JPG" width=480 onload=ResizeImage(this,560,1000) border=0></P>
    <P><IMG height=420 alt=按此在新窗口浏览图片 src="http://blog.nnsky.com/photo/20082/37091/200821662038.JPG" width=560 border=0 ="ResizeImage(this,560,1000)"></P>
    <P>&gt;</P>
    </textarea> 
    <br/> 
    <input type='button' value='提交' onclick='Replace()'/>
      

  4.   

    非常感谢 muxrwc
    经测试,一切正常,大功告成!
    我会在我的系统这段代码中写上by muxrwc呵呵,马上结贴。
      

  5.   

    www
    改为
    [^\/]*?
    就好了lz不厚道啊
    muxrwc出手才给的0分