Re: Strip emails from a document

From: Date: Sat, 26 Jan 2013 16:54:57 +0000
Subject: Re: Strip emails from a document
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-320106@lists.php.net to get a copy of this message
I think you meant extract emails from document, right? I'd probably find @ and iterate before and after unless I get posix punct, space, characters. But it'll probably give some false matches. So its really hard to find 100% emails from an arbitrary text. This is because valid email can contain many different type of characters. According to RFC 822 space is a valid character in email. So finding all the valid emails is tough. In a *trivial situation* an email would be separated by space. So find @ first. Then go back and front to find the first space. You'll get most common emails. Something like using this regex pattern [^[:space:]<@]+@[^[:space:]>]+ would suffice. But keep in mind, it'll work on trivial cases. Not on special cases. Regular expression can not be used on special cases. Here is full RFC-822 compliant email matching regular expression http://ex-parrot.com/~pdw/Mail-RFC822-Address.html More information can be found on http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address On Sat, Jan 26, 2013 at 10:24 PM, Tedd Sperling <tedd@sperling.com> wrote: > Hi gang: > > I thought I had a function to strip emails from a document, but I can't > find it. > > So, before I start writing a common script, do any of you have a simple > script to do this? > > Here's an example of the problem: > > Before: > > "Will Alex" <alex13@cit.msu.edu>;"Moita Zact" > <zact3@cit.msu.edu>;"Bob > Arms" <arms1@cit.msu.edu>;"Meia Terms" <termsma@cit.msu.edu>; > > After: > > alex13@cit.msu.edu > zact3@cit.msu.edu > arms1@cit.msu.edu > termsma@cit.msu.edu > > Cheers, > > tedd > > > _____________________ > tedd@sperling.com > http://sperling.com > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader

« previous php.general (#320106) next »