I'm trying to validate a e-mail string in Java but I'm getting trouble to validate when this string has two or more special chars toghether, which is not a valid e-mail.
My if that does this validation is the following:
if (email.matches("(._\'!#$%&*+-\\/=?{|}~`^_-)\\1+")) {
return false;
}
Example for the output:
this_e-mail's_valid@domain.com - return true (CORRECT)
this_e-mail_isn''t_valid@domain.com - return true (WRONG)
Obviously there's something wrong with my regular expression.
But I looked all over the internet to find some answer but didn't succeeded.
I've just read that using the "\1+" before expression, it was supposed to do this validation, but apparently it doesn't.
Thanks in advance for the answers!