Code snippet to verify the provided string is in email format or not and returns back the boolean value.
public static boolean isEmail(String email) {
Pattern pattern = Pattern
.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
Matcher matcher = pattern.matcher(email);
return matcher.matches();
}
Comments
Post a Comment