Java Email Validate isEmail(String val)

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

Description

is Email

License

Apache License

Declaration

public static boolean isEmail(String val) 

Method Source Code


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

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

public class Main {
    private static final String EMAIL_REGEXP = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";

    public static boolean isEmail(String val) {
        boolean result = false;

        Pattern p = Pattern.compile(EMAIL_REGEXP);
        Matcher m = p.matcher(val);
        try {//from w ww.  ja  v  a2s .  c  o  m
            return m.matches();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }
}

Related

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