Rob Prime wrote:The part between the @ and the a-z / A-Z part needs reworking. You can have multiple subdomains; back at University I had an @student.tue.nl email address. So you want to quantify the [^\\s] and dot together as well: ([^\\s]+\\.)*. That * means that rob@localhost is still allowed.
[^\\s] will match a dot so multiple domain levels are matched. Good point about matching single level domains. Whether or not to allow that may be application dependent I guess. May be localhost should be your only single level domain allowed? E.g.
^[^\\s]+@(([^\\s].*\\.[a-zA-Z]+)|(localhost))$
If you do allow single level names in general,
you should also consider allowing a wider range of characters than [a-zA-Z] for that name. Would you allow DonJuan@MaƱana1 as an example?

(not sure if this looks right on your screen)
Rob Prime wrote:
If I need to do any email address format validation I usually just use javax.mail.internet.InternetAddress
Another good point.