
Email Address Validation Using a Regular Expression
The following code demonstrates how to validate email using regular expression: import java.util.regex.*;class regexSample { public static void main(String args[]) { //Input the string for validation String email = “[email protected]”; //Set the email pattern string Pattern p = Pattern.compile(“[email protected]+\.[a-z]+”); //Match the given string with the pattern Matcher m = p.matcher(email);