I am using java regex package to validate an email as below:
Pattern p = Pattern.compile("^[ _A-Za-z0-9-]+(\\.[ _A-Za-z0-9-]+)*@"
+ "[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,4})$");
This pattern works fine for accepting one email throw textbox. But, now I need a pattern that will validate multiple emails separated by commas.
Can any one tell me the pattern?
Something like the following:
Or, alternatively, first split the string using
split("\\s*,\\s*"), then iterate over the array and validate each email address using your pattern.