regex and HTML
First of all,
This works wonderfully for gleaning links and email addrs from a block of text. The problem is that the text may also contain HTML tags which contain web and email links.
Without stripping the HTML, what is the easiest way to prevent in tag links from being linked themselves?
My first thought was to add something to the regex that would check for a beginning whitespace character, but I don't know how to write this in the code.
// make links
$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
"\\0", $text);
// make email links
$text = ereg_replace('[_a-zA-z0-9\-]+(\.[_a-zA-z0-9\-]+)*\@' . '[_a-zA-z0-9\-]+(\.[a-zA-z]{1,3})+',
'\\0', $text);
This works wonderfully for gleaning links and email addrs from a block of text. The problem is that the text may also contain HTML tags which contain web and email links.
Without stripping the HTML, what is the easiest way to prevent in tag links from being linked themselves?
My first thought was to add something to the regex that would check for a beginning whitespace character, but I don't know how to write this in the code.
