How do I go about getting link text (like markdown). Say some one types
(Google)[https://google.com]
The result would look like:
<a href="https://google.com">Google</a>
Here's my current function:
function MakeUrls($str)
{
$find=array('`((?:https?|ftp)://\S+[[:alnum:]]/?)`si','`((?<!//)(www\.\S+[[:alnum:]]/?))`si');
$replace=array('<a href="$1" target="_blank"> $0</a>', '<a href="http://$1" target="_blank">$1</a>');
return preg_replace($find,$replace,$str);
}
When someone types https://google.com it returns:
<a href="https://google.com" target="_blank"> https://google.com</a>