查看完整版本: 一个正则表达式,判断一段留言中是否有URL,在显示的时候加上超连接

Kenny 2007-8-2 13:31

一个正则表达式,判断一段留言中是否有URL,在显示的时候加上超连接

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