Wednesday, April 07, 2010

Java Email validation using Regex

public boolean isValidEmailAddress(String email) {
Pattern p = Pattern.compile("^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$");
Matcher m = p.matcher(email);
return m.matches();
}

1 comment:

Syed Sibte Shah said...

Hey I didn't know that you had a blog. Keep posting!