比如..有一个地址http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=467d91e3-dd1还有一个  textarea  用户输入了连续的地址..
________________________________________________________________________________________________________________
http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=467d91e3-dd1http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=467d91e3-dd1http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=467d91e3-dd1http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=467d91e3-dd1http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=467d91e3-dd1
________________________________________________________________________________________________________________TMD..用正则去匹配出所有的地址来..也就是说.不以  http 结尾.
但.. 不知道咋办了-_-核心问题就是..........        不以  htt 结尾的 字符串..     用来搜索这个里面的地址替换成  带  href 的.目前的正则是:var reg=/http(s)?:\/\/([\w\u4e00-\u9fa5-]+\.)+[\w\u4e00-\u9fa5-]+((:\d+)?)+(\/[\w.\:\_\.\-\'+?%&=]+)*[^http(s)\:\/\/|<|\,|\ |\'|\;]/ig;因为  [^http(s) 这句话..-_-http://www.ysfflq.com.cn/article/view-473f48.asphttp://www.ysfslq.com.cn/article/view-14748.asp
这句会变成
<a href=http://www.ysfflq.com.cn/article/view-473f48.a target=_blank>http://www.ysfflq.com.cn/article/view-473f48.a</a>
sp<a href=http://www.ysfslq.com.cn/article/view-14748.a target=_blank>http://www.ysfslq.com.cn/article/view-14748.a</a>
sp<br/>求不以   htt 结尾的正则-_-

解决方案 »

  1.   

    这个觉得用split比较好。result = subject.split(/http:\/\//);
      

  2.   

    先用split('http:\/\/')将其拆分,然后再做你想要的结果处理
      

  3.   

    如果是
    http://wwwwwwwwwwww.xxx
    http://wwwwwwwwwwww.xxx 这是内容..这还是内容..这又是  http://wwwwwwwwwwww.xxx
    http://wwwwwwwwwwww.xxxhttp://wwwwwwwwwwww.xxx 这你就迷糊了.所以..这种写法不可取喽..
    我用  replace 把  "http" 换成  " http" 这样..  http 与 前面的字符就有空格了..这么处理的.
    结果ok
      

  4.   

    var reg=/http(s)?:\/\/([\w\u4e00-\u9fa5-]+\.)+[\w\u4e00-\u9fa5-]+((:\d+)?)+(\/[\w.\:\_\.\-\'+?%&=]+)*[ ^(http\:\/\/)|^(https\:\/\/)|<|\,|\ |\'|\;]/ig;
      

  5.   

    这样?
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>测试TypeOf</title></head>
    <body>
    http://www.sohu.comhttp://www.sina.com
    http://www.163.com http://qq.tecent.com
    http: //www.baidu.comhttp: //1wwwwwwwwwww.xx1
    http: //2wwwwwwwwwwww.xx2 这是内容..这还是内容..这又是 http://3wwwwwwwwwww.xx3
    http: //4wwwwwwwwwww.xx4http: //5wwwwwwwwwww.xx5 这你就迷糊了.
    </body>
    </html>
    <script type="text/javascript">
    var html=document.body.innerHTML;
    var reg=/(http:\s*\/\/\w+)((\.\w+)+)/gi;
    var array=[];
    var url;while(reg.exec(html)){
    url=RegExp.$1+RegExp.$2;
    if(url.match(/.*?http$/i)){
    array.push(url.substring(0,url.length-4));
    reg.lastIndex-=4;
    }else{
    array.push(url);
    }
    }alert(array.join("\n"));
    </script>