Kenny 2007-8-2 13:31
一个正则表达式,判断一段留言中是否有URL,在显示的时候加上超连接
<p> $string = &quot;连接http://www.phpx.com 站点&quot;;<br> <BR>//连接后需要有个空格或回车。<br> <BR><br> <BR>$string =&nbsp;&nbsp;eregi_replace(&quot;http://([^ ,\r\n]*)&quot;,&quot;&lt;a href=http://www.phpchina.com/\\0 target=_blank&gt;\\0&lt;/a&gt;&quot;,$string);<br> <BR>$string =&nbsp;&nbsp;eregi_replace(&quot;ftp://([^ ,\r\n]*)&quot;,&quot;&lt;a href=http://www.phpchina.com/\\0 target=_blank&gt;\\0&lt;/a&gt;&quot;,$string);<br> <BR><br> <BR>print $string;</p> <center><input type="image" onclick=copyToClipBoard() src="http://www.phpchina.com/images/phpcn_book_bu_tj.gif" border="0"></center>