The code I'm using works fine for parsing a link that isn't between <a> tags. However, when one is, it ruins the link by spouting out a bad link. I'd like to have it ignore any link that is preceeded by Href=, to stop this behavior. Unfortunately, I'm horrible with regular expressions, and I could use some helping in modifying my search expression.
Here's the code for the function I'm using right now:
function parseHyper($string)
{
$search = array ("/([\w\.\/\&\=\?\-]+)@([\w\.\/\&\=\?\-]+)/",
"/((ftp(7?):\/\/)|(ftp\.))([\w\.\/\&\=\?\-]+)/",
"/((http(s?):\/\/)|(www\.))([\w\.\/\&\=\?\-]+)/");
$replace = array ("<a href='mailto:$1@$2'>$1@$2</a>",
"<a href='ftp$3://$4$5' target='_blank'>$4$5</a>",
"<a href='http$3://$4$5' target='_blank'>$4$5</a>");
return preg_replace ($search, $replace, $string);
}
I'd appreciate any help. thanks.