Posted By

nialace on 11/21/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

alexvezeau


verification email


 / Published in: Java
 

verification of email format with regex

  1. String value="[email protected]";
  2.  
  3. java.util.regex.Pattern p = java.util.regex.Pattern.compile("^[a-zA-Z]+[a-zA-Z0-9\\._-]*[a-zA-Z0-9]@[a-zA-Z]+"
  4. + "[a-zA-Z0-9\\._-]*[a-zA-Z0-9]+\\.[a-zA-Z]{2,4}$");
  5. java.util.regex.Matcher m = p.matcher(value);
  6.  
  7.  
  8.  
  9. if(m.find())
  10. System.out.println("ok");
  11. else
  12. System.out.println("ko");

Report this snippet  

You need to login to post a comment.