Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!usr/bin/perl -w
- use strict;
- foreach my $line (<DATA>) {
- print "$1\@$2\n" if $line =~
- m/([\w\._0-9]+)\@([\w0-9]+(\.[\w0-9]+)+)\.?/g;
- # after matching, $1 holds the email
- # and $2 holds the domain
- }
- __DATA__
- Lorem ipsum dolor sit amet.
- This line does not contain an email.
- This line has an email: neo@matrix.com.
- Only "neo@matrix.com" is matched, even
- though there's a dot at the end.
- test.sample@gmail.com
- not_a_valid@email
- emails are matched@in.the middle
- __leading.underscores__@are.matched
- several.dots.will@still.match
- but only one dot can be in@the.domain.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement