Advertisement
Guest User

Untitled

a guest
Nov 5th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) {
  7.  
  8. String str[]={
  9. "test@google.com",
  10. "test.test@google.com",
  11. "test.test@google.com.pl",
  12. "test123@google.com",
  13. "test_test@google.com",
  14. "123test.test@google.com",
  15. "123test.test@google.pl",
  16. "aaaa_a.a@google.com",
  17. "!@google.com",
  18. "aaa_aaaaaa@google.com.pl.pl.pl.pl"
  19. };
  20.  
  21. Pattern p = Pattern.compile("^.*a[a-zA-Z0-9]+([\\._]?[a-zA-Z0-9])*@[A-Za-z0-9]{2,}(\\.[a-z]{2,})+$");
  22. Matcher m = null;
  23.  
  24. for (int i=0; i<str.length; i++){
  25. System.out.print(str[i] + " : ");
  26. m = p.matcher(str[i]);
  27. System.out.println(m.matches());
  28. }
  29.  
  30.  
  31.  
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement