You can use the below validator class for email address in your java projects,
/* Email Validator */ package com.tms.utility; import java.util.regex.Pattern; /** * * @author aarnav */ public class EmailValidator { private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; public EmailValidator() { } /** * Validate hex with regular expression * * @param email for validation * @return true valid email, false invalid email */ public static boolean validate(String email) { Pattern pattern = Pattern.compile(EMAIL_PATTERN); return pattern.matcher(email).matches(); } }
I ‘ve been searching for it, you saved me. Thanks!
Welcome !
tihs is what I was looking for.
Great site and ocntent