// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.regex.*;

public class EmailSplit {
    public static boolean check1(String email) {
        String[] parts = email.split("@");
        if(parts.length != 2) {
            return false;
        } else {
            String[] first = parts[0].split("\\.");
            if(first.length > 3) {
                return false;
            } else {
                return true;
            }
        }

    }
    private static Pattern p = Pattern.compile("(\\w+(\\.\\w+){0,2}@\\w+(\\.\\w+)+)");
    public static boolean check2(String email) {
        return p.matcher(email).matches();
    }
    public static void test(String email) {
        System.out.println(email + " " + check1(email) + " " + check2(email));
    }
    public static void main(String[] args) {
        test("a.b@d.c.d");
        test("a.b.c@d.e.f");
        test("a.b.c.d@e.f.g.h");
        test("ups");
        test("x@x@x");
    }
}
