这个函数从一个字符串创建链接,但问题是,如果我已经有一个链接,它就不起作用,例如:'我是一个链接',但它适用于'我是链接http://www.google.com '。任何的想法?
function checkStringForLinks($string)
{
/*** make sure there is an http:// on all URLs ***/
//$string = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i", "$1http://$2",$string);
/*** make all URLs links ***/
$string = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</A>",$string);
/*** make all emails hot links ***/
//$string = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<A HREF=\"mailto:$1\">$1</A>",$string);
return $string;
}
哎呀,输入错误。我的意思是:我不希望它接触 \anchor\link\anchor\,而是只接触未形成的链接