Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Main {
- public static void main(String[] args) {
- String str[]={
- "test@google.com",
- "test.test@google.com",
- "test.test@google.com.pl",
- "test123@google.com",
- "test_test@google.com",
- "123test.test@google.com",
- "123test.test@google.pl",
- "aaaa_a.a@google.com",
- "!@google.com",
- "aaa_aaaaaa@google.com.pl.pl.pl.pl"
- };
- Pattern p = Pattern.compile("^.*a[a-zA-Z0-9]+([\\._]?[a-zA-Z0-9])*@[A-Za-z0-9]{2,}(\\.[a-z]{2,})+$");
- Matcher m = null;
- for (int i=0; i<str.length; i++){
- System.out.print(str[i] + " : ");
- m = p.matcher(str[i]);
- System.out.println(m.matches());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement