Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

(dkubb) Re: (2) pattern match e-mail addresses

by dkubb (Deacon)
on Mar 23, 2001 at 07:27 UTC ( [id://66558]=note: print w/replies, xml ) Need Help??


in reply to Re: pattern match e-mail addresses
in thread pattern match e-mail addresses

There is a CPAN module that will match email addresses inside a string; Email::Find. Here's an example using this module:

#!/usr/bin/perl -w use strict; use Email::Find qw(find_emails); use vars qw(@MATCHES); my $text = 'user@somewhere.com not an email address me@home.com'; find_emails($text, \&callback); print join "\n", @MATCHES; sub callback { my $email = shift; my $original = shift; push @MATCHES, $email->format; return $original; }

Warning: the find_emails() routine will modify the original text. Make sure that you always return the original email text (as shown above), so that your input text does not mysteriously change.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://66558]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-04-23 13:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found