Re: Strip emails from a document
| From: | Tedd Sperling | Date: | Sat, 26 Jan 2013 17:29:30 +0000 |
| Subject: | Re: Strip emails from a document | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-320108@lists.php.net to get a copy of this message | ||
On Jan 26, 2013, at 12:20 PM, Daniel Brown <danbrown@php.net> wrote:
>
> It's imperfect, but will work for the majority of emails:
>
> <?php
> function scrape_emails($input) {
>
> preg_match_all("/\b([a-z0-9%\._\+\-]+@[a-z0-9-\.]+\.[a-z]{2,6})\b/Ui",$input,$matches);
> return $matches;
> }
> ?>
It works imperfectly enough for me. :-)
Here's the result:
http://www.webbytedd.com/aa/strip-email/index.php
Thanks to all.
Cheers,
tedd
PS: Yes, 'extract" is what I meant and more correct than 'strip' as I said.
_____________________
tedd@sperling.com
http://sperling.com