Re: Assigning pattern matches to an array
- From: "DJ Stunks" <DJStunks@xxxxxxxxx>
- Date: 30 Dec 2006 15:29:00 -0800
Graham Stow wrote:
"DJ Stunks" <DJStunks@xxxxxxxxx> wrote in message
news:1167506565.933525.68510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Graham Stow wrote:
push(@matches, $line=~/\b\w+@\w+\b/g); did it for me
The pattern doesn't match an email address, but I can work on that...
well, for one thing, the \w metacharacter doesn't match a literal .
don't roll your own email address regexp.
perldoc Email::Address
Emaill::Address doesn't grab me
Done a quick test between
use Email::Address
push(@matches, Email::Address->parse($line));
and
push(@matches, $line=~/\b[.-\w]*@[-\w]*\.+[-\w]*\.*[-\w]*\b/g);
The latter pulled up a number of correct email address, while the former
pulled these up plus other stuff that weren't true email addresses
try (untested):
push @matches, map { $_->address } Email::Address->parse($line);
-jp
.
- Follow-Ups:
- Re: Assigning pattern matches to an array
- From: Graham Stow
- Re: Assigning pattern matches to an array
- References:
- Assigning pattern matches to an array
- From: Graham Stow
- Re: Assigning pattern matches to an array
- From: Uri Guttman
- Re: Assigning pattern matches to an array
- From: Graham Stow
- Re: Assigning pattern matches to an array
- From: DJ Stunks
- Re: Assigning pattern matches to an array
- From: Graham Stow
- Assigning pattern matches to an array
- Prev by Date: Re: Assigning pattern matches to an array
- Next by Date: Re: Problem by pushing a String and a Hash on an array!
- Previous by thread: Re: Assigning pattern matches to an array
- Next by thread: Re: Assigning pattern matches to an array
- Index(es):
Relevant Pages
|