Use \Z to match end of string or newline and \z to match only end of string.
I've long been under the impression that domain names are allowed to have a single trailing dot. That is, "example.com" is the same as "example.com.". As a lame proof of this, dig tells me gives me the same answer either way, but it rejects "example.com.." (not a legal name). I haven't looked closely at RFC1035 for support for this. If you accept this, it screws up the "lc eq lc" test for equality. Maybe you'd want to just s/\.?\s*$// everything before anything else.
Yes, I realize that it is possible to set up a system such that ExpertsExchange@example.com and ExpertSexchange@example.com are completely separate addresses, but anybody who does that deserves to suffer from such a set-up.
Unfortunately, it's usually not the people who set it up who suffer but rather the people who have to use it and often have no control over it. I don't think that ignoring the case of the local part of an email address is a bad design decision—I've done it myself at times. I think, rather, that it's better justified on the grounds that the few mistakes aren't worth the extra work to avoid them.
At YAPC::NA 2008, I attended a talk by Ricardo SIGNES (rjbs) called "Email Hates the Living!" which discussed some of the pitfalls of parsing email addresses strictly according to the standards. Google knows about it. You might pass that along to anyone else who wants to take an approach less practical than yours. Also, it's hilarious.
In reply to Re: Practical e-mail address validation
by kyle
in thread Practical e-mail address validation
by tye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |