[olug] First Ruby on Rails user group meeting 08/20/2008 (and regex question)
Luke Dashjr
luke at dashjr.org
Mon Aug 18 16:32:36 UTC 2008
On Monday 18 August 2008 09:58:58 Dan Linder wrote:
> On Mon, Aug 18, 2008 at 9:18 AM, Adam Haeder <adamh at aiminstitute.org>
wrote:
> > I'm attempting to write a shell script that will pull email addresses out
> > of a file. These addresses may appear anywhere in a line. I think what
> > I'm essentially looking for is a 'substring grep'. I want a grep that
> > will give me part of a line that matches a regex. I've been toying with
> > the idea of doing something like this:
>
> How about this:
> $ cat testfile.emails
> no e-mail on this line
> there's one here dan at linder.org here is one
> nothing
> joe@ someplace
> joe at google.com
> john at someplace
> none
> nada
>
> $ perl -ne 'printf "%s\n", $1 if m/([\w\.]+\@[\w\.]+)/' testfile.emails
> dan at linder.org
> joe at google.com
> john at someplace
>
> (I'm sure someone will follow up with a perl-golf entry for a smaller
> command line...Jay?)
>
> Dan
http://thefrozenfire.com/data/emailregex.txt
More information about the OLUG
mailing list