Your regex doesn't come close to matching valid email addresses:
| [A-Za-z0-9._%-] |
matches one letter, digit, dot, underscore, percent or dash character |
| \@ |
an "at" sign
|
| [A-Za-z0-9_%-.] |
matches one letter, digit, underscore, percent, dash or dot character. Update: it gets worse: %-. is a range, so any one of '%&\'()*+,-.' would also match |
| . |
any single character except a newline |
| [com] |
matches the letter 'c', 'o' or 'm' |
But unforunately both of them are matching .com.com
It matches much more than that:
/[A-Za-z0-9._%-]\@[A-Za-z0-9_%-.].[com]/ and say "'$_' matched"
for 'x@zzc', 'a b c@c!c', '?@?@?e@a.m';
__END__
'x@zzc' matched
'a b c@c!c' matched
'?@?@?e@a.m' matched
As others have said, the only way to truly validate an email address is to send mail to it, and hope the owner replies.
Update: updated the second character class
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.