RE: [PHP] preg_replace and emails
| From: | Michael | Date: | Sun, 04 May 2003 21:54:34 +0000 |
| Subject: | RE: [PHP] preg_replace and emails | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146381@lists.php.net to get a copy of this message | ||
http://www.php.net/manual/en/pcre.pattern.syntax.php
I read the above page and supposely if I add (?<!foo)bar then it will find
an occurance of "bar" that is not preceeded by "foo" but it's not working
for me.
What am I doing wrong?
!!!!!!!!!!!!
$text =
preg_replace("/(?<!mailto:)([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-
Z]{2,3}|[0-9]{1,3})(\]?))/i","<A HREF=\"mailto:$1\">$1</A>", $text);
-----Original Message-----
From: David Otton [mailto:phpmail@jawbone.freeserve.co.uk]
Sent: May 4, 2003 2:31 PM
To: Michael
Cc: Php-General@Lists.Php.Net
Subject: Re: [PHP] preg_replace and emails
On Sun, 4 May 2003 12:48:16 -0400, you wrote:
>"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?
I had a reply ready to go, but it occurs to me that someone dealing with
email addresses in the form "<a
href="mailto:mike@yahoo.com">mike@yahoo.com</a>"
/before/ processing, is
screen-scraping them.
Just to set my mind at rest before I post, what exactly are you trying
to do?
---
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/03
---
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/03
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/03
---
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/03