preg_replace and emails
| From: | Michael | Date: | Sun, 04 May 2003 16:48:16 +0000 |
| Subject: | preg_replace and emails | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-146371@lists.php.net to get a copy of this message | ||
I found this regex that does this:
"mike@yahoo.com" converts to "<a
href="mailto:mike@yahoo.com">mike@yahoo.com</a>"
$text =
preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9
]{1,3})(\]?))/i","<A HREF=\"mailto:$1\">$1</A>", $text);
... but I'm having problems with this:
"<a href="mailto:mike@yahoo.com">mike@yahoo.com</a>"
converts to
"<a href="mailto:<a href="mailto:mike@yahoo.com">mike@yahoo.com</a>"><a
href="mailto:mike@yahoo.com">mike@yahoo.com</a></a>"
What do I need to include in the regex to not do it if "mailto:" is infront
of the email address?
---
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/03