Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static final boolean isValidEmail(final String email) {
        boolean result = false;
        if (email != null) {
            // \\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*
            Pattern pattern = Pattern.compile("\\w+(\\.\\w+)*@\\w+(\\.\\w+)+");
            Matcher matcher = pattern.matcher(email.trim());
            result = matcher.matches();
        }
        return result;
    }
}