现在 我使用的preg_replace的网址和链接
$content = preg_replace('@(https?://([-\w\.]+)+(:\d+)?((/[\w/_\.%\-+~]*)?(\?\S+)?)?)@', '<a href="$1" target="_blank">$1</a>', $content);
用于替换链接URL,但它并没有与像#一些符号和其他许多
和我也想工作如果内容看起来像这样
<a href="http://www.abc.com/">http://www.abc.com/</a>
然后preg_replace跳过这个,否则它会重复相同并产生错误的结果。
这个问题被问了很多。尝试搜索:“php linkify url” – ridgerunner 2011-12-22 17:57:08
或者如果你绝望:http://txt2re.com/ – user978122 2011-12-22 18:27:30