Packagecom.xxx.xxx; Public classDemo6 {/*** Regular expression Verification e-mail *@paramargs*/ Public Static voidMain (string[] args) {//to define a regular expression to match an E_Mail addressString regex = "\\[email protected]\\w+ (\\.\\w{2,3}) *\\.\\w{2,3}"; //define the string to be validatedString str1 = "[Email protected]"; String str2= "AAAA"; String STR3= "[Email protected]"; if(Str1.matches (Regex)) {//to determine if a string variable matches a regular expressionSystem.out.println (str1+ "is a valid E_Mail address format"); } if(Str2.matches (Regex)) {//to determine if a string variable matches a regular expressionSystem.out.println (str2+ "is a valid E_Mail address format"); } if(Str3.matches (Regex)) {//to determine if a string variable matches a regular expressionSystem.out.println (str3+ "is a valid E_Mail address format"); } }}
5. Regular Expression Verification mailbox