Posted by: Wayne | July 15, 2008

Regex that may scare you

I am in the middle of implementing some Java codes that validate a user’s input, and I have found that handling invalid email address formats may be much harder than I thought.

Rather than coming up with the regex for the validation by myself, I was looking for some ready-made regex for it. Luckily I found one, but that was remarkably complex than I thought. For those who are interested in it please drop by this website, http://ex-parrot.com/~pdw/Mail-RFC822-Address.html.

However, I also found that Sun Microsystems introduced JavaMail API that is dedicated to handling message and email-related work based on Java. I still need to take a closer look at that package, but my understanding so far is that the package contains several classes whose constructor somehow validates an email address when it is passed into the class’ constructor as a parameter. That may help me stay away from the validation issues by delegating it.


Leave a response

Your response:

Categories