----- Original Message -----
From: Kevin Smith <sent / qualitycode.com>
To: ruby-talk ML <ruby-talk / ruby-lang.org>
Sent: Wednesday, March 14, 2001 6:12 PM
Subject: [ruby-talk:12663] Re: email address regexp


> jjthrash / pobox.com wrote:
> >On Thu, Mar 15, 2001 at 02:20:14AM +0900, David Fung wrote:
> >> i would like to locate probable email addresses in a bunch of text
files,
> >> but don't know how to build a regexp for the search.  glad if somebody
can
> >> help.
> >
> >/\w+@\w+(\.\w+)+/
> >
> >should probably work.  That is
>
> I'm not a regex expert, but that appears to
> require a dot after the @. Technically, that's
> the dot is not required. My brother did some
> research and found a guy whose email address is
> in a top-level domain. Something like xxx@edu (I
> forget the actual details).
>
> Anyway, 99.999% of email addresses will have a
> dot, but if you want to catch EVERY address, you
> can't make that assumption.
>
> Kevin

Actually, the real regex to match *every* email address
would be of horrifying complexity. After all, even an IP
address is valid inside it, isn't it? And even an IP is not
quite trivial.

See Jeff Friedl's book _Mastering Regular Expressions_
for more on this.

Hal Fulton