开发者

Get email from string [duplicate]

开发者 https://www.devze.com 2023-01-26 23:46 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: How to extract email address from a string using perl?
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

How to extract email address from a string using perl?

Say I have a string like this:

Dr. X University of School name in nowhere pete@school.edu Bl开发者_JS百科ah blah 3 one niner

How would I get the email out of there?


You can try Email::Find.

#!/usr/bin/perl

use strict; use warnings;
use YAML;
use Email::Find;

my $finder = Email::Find->new(\&print_email);

while ( my $data = <DATA> ) {
    $finder->find(\$data);
}

sub print_email {
    print Dump \@_;
}

__DATA__
Say I have a string like this:

Dr. X University of School name in nowhere pete@school.edu Blah blah 3 one niner

How would I get the email out of there?

Output:

---
- !!perl/array:Mail::Address
  - ''
  - pete@school.edu
- pete@school.edu


You do not say the language but you could use this method:

http://www.codeproject.com/KB/vb/extractemail.aspx http://www.webdeveloper.com/forum/showthread.php?t=200875

and there were many others on Google (no offense, just what I saw for helping you.)

0

精彩评论

暂无评论...
验证码 换一张
取 消