Reputation: 1519
In my project I give email address to send the mail in a text box. I can give either a single email address or a multiple email address separated by commas. Is there any regular expression for this situation. I used the following code and its check for single email address only.
public static boolean isEmailValid(String email){
boolean isValid = false;
String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";
CharSequence inputStr = email;
Pattern pattern = Pattern.compile(expression,Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
if(matcher.matches()){
isValid = true;
}
return isValid;
}
Upvotes: 0
Views: 2072
Reputation: 4285
Upvotes: 1
Reputation: 1997
You can split your email-var on a ",", and check for each emailaddress you got :)
Upvotes: 0