--- Chuck <[EMAIL PROTECTED]> wrote:
> 
> I need to grab an email address from an arbitrary string of  text. The
> string will only have 1 '@' symbol.
> 
> I need a regexp that will search for this symbol and return the whole word.
> 
> It will appear like this:
> 
> blah blah blah 12112 blah [EMAIL PROTECTED] blah some more text.....
> 
> I want to grab the email address and place it in a variable.
> 
> Can anyone help me out?
> 
> Thanks,
> CC

Check out Email::Find 
(http://theoryx5.uwinnipeg.ca/CPAN/data/Email-Find/Email/Find.html). 
Writing your own regex to parse email addresses is non-trivial and, in fact, 
impossible.  Even the
huge regex for matching email addresses that is found in Mastering Regular Expressions 
is
acknoweldged by the author to be imperfect.  Due to the way that email addresses are 
defined by
RFC 822, it's very, very difficult to be sure you're matching them properly.

To consider the difficulty of doing this yourself, consider the following 
syntactically valid
email addresses (lifted directly from page 218 of CGI Programming with Perl, second 
edition):

    Alfred Neuman <Neuman@BBN-TENEXA>
    ":sysmail"@ Some-Group. Some-Org
    Muhammed.(I am  the greatest) Ali @(the)Vegas.WBA

Cheers,
Curtis "Ovid" Poe

=====
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to