Posted by tech on
May 22, 2008
|
(No Ratings Yet)
Loading ...
|
|
isEmail() method for Java checks if an email address is valid or not. returns boolean.
1
2
3
4
5
6
7
| public static String emailPattern = "^[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]$";
public static boolean isEmail(String email) {
Pattern p = Pattern.compile(emailPattern); // Set the email pattern string
Matcher m = p.matcher(email); // Match the given string with the pattern
return m.matches();
} |
Found this post useful? Buy me a cup of coffee or help support the sponsors on the right.
June 26th, 2009 at 2:58 pm
Muchas gracias……!!!!!!
June 26th, 2009 at 3:18 pm
Hay que importar esto:
java.util.regex.Pattern
java.util.regex.Matcher