不会吧?
<?
function autourl($messagetext)
{   
  //-----自动URL-----------
    $urlSearchArray = array(
      "/([^]_a-z0-9-=\"'\/])((https?|ftp|rtsp|mms|gopher|news|telnet):\/\/|www\.)([^ \r\n\(\)\*\^\$!`\"'\|\[\]\{\};<>]*)\b/si",
      "/^((https?|ftp|gopher|news|telnet):\/\/|www\.)([^ \r\n\(\)\*\^\$!`\"'\|\[\]\{\};<>]*)\b/si"
    );
    $urlReplaceArray = array( 
     "\\1\\2\\4",  
    "\\1\\3
   );
    $emailSearchArray = array(  
    "/([ \n\r\t])([\\._a-zA-Z0-9-]+(\.[\\._a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3}))/si",
      "/^([\\._a-zA-Z0-9-]+(\.[\\._a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3}))/si"    );      $emailReplaceArray = array(
      "\\1\\2",
      "\\0"
    );  $text = preg_replace($urlSearchArray, $urlReplaceArray, $messagetext);
  if (strpos($text, "@")) {
    $text = preg_replace($emailSearchArray, $emailReplaceArray, $text); 
 }
  return $text;
}
echo autourl("http://bbs.soulsky.net测试");
?>
输出
http://bbs.soulsky.net测试

解决方案 »

  1.   

    to xuzuning(唠叨) :你只是在$urlSearchArray = array(
          "/([^]_a-z0-9-=\"'\/])((https?|ftp|rtsp|mms|gopher|news|telnet):\/\/|www\.)([^ \r\n\(\)\*\^\$!`\"'\|\[\]\{\};<>]*)/si",
          "/^((https?|ftp|gopher|news|telnet):\/\/|www\.)([^ \r\n\(\)\*\^\$!`\"'\|\[\]\{\};<>]*)/si"
        );
    这个的/si前面加了一个\b吧
      

  2.   

    我用了,发现只有当.net后面跟着空格的时候才可以整个url,如果连着汉字,只能url到net前面那个点。
    例:
      

  3.   

    http://bbs.soulsky.net/wdbread.php?forumid=9&filename=f_437&page=last
    另外,为什么email未被分析呢?