On Thu, 15 Mar 2001 02:46:50 +0900,
jjthrash / pobox.com <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
+
+stuff.grep(/\w+@\w+(\.\w+)+/)
+
+Now, this is assuming an email address can only be made up of
+chracters from a-zA-Z0-9_. I don't know if that's a real
+limitation. I think it is a limitation on the domain name, so
+the following might work:
+
+/.+@\w+(\.\w+)+/
+
the problem w/email addresses and regexes is that you can have
comments nested to an arbitrary level.
user@machine(nested(comments(ok(in(email(address)))))).foo.bar
is one example of a valid email address, if "user / machine.foo.bar"
exists it should be delivered. regex grammar does not extend to
nested thingies, you need a parser for that.
Pete
--
ruby -F- -e '$, = $; . sub /./, " Another "; print %w.Just Rewbie .. join'