Java Email Validate isEmail(String str)

Here you can find the source of isEmail(String str)

Description

is Email

License

Apache License

Declaration

public static boolean isEmail(String str) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static boolean isEmail(String str) {
        boolean result = validByRegex(
                "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$", str);
        return result;
    }//from w  w w .  j a  v a2s.c om

    public static boolean validByRegex(String regex, String str) {
        Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
        Matcher regexMatcher = pattern.matcher(str);
        return regexMatcher.find();
    }
}

Related

  1. isEmail(String str)
  2. isEmail(String str)
  3. isEmail(String str)
  4. isEmail(String str)
  5. isEmail(String str)
  6. isEmail(String str, boolean nullCheck)
  7. isEmail(String string)
  8. isEmail(String string)
  9. isEmail(String text)