Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Validates the email.
     * @param email - Email.
     * @return - True (if is valid) or False (otherwise).
     */
    public static boolean validateEmail(String email) {
        if (email == null || email.length() == 0 || !email.matches(
                "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"))
            return false;

        return true;
    }
}