I'm trying to find out how to remove all invalid characters in an email address.
Ex: email="taeo͝';st@yy.com"(. is an email character) and the result should be: email = "taest@yy.com"
I'm using the following email pattern:
String email_pattern = "^[^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$]";
String modifiedEmail = email.replaceAll(email_pattern,"");
But the above code is giving the result: email = "aest@yy.com" but expected "taest@yy.com"
Any suggestions or a better approach would be appreciated.