Java Email Validate isEmail(String s)

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

Description

Checks whether s is a valid email address or not.

License

LGPL

Parameter

Parameter Description
s string to check

Return

true if s is a valid email address

Declaration

public static boolean isEmail(String s) 

Method Source Code

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

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

public class Main {
    /**/*  www.java  2  s .co  m*/
     * Checks whether s is a valid email address or not. The method checks using a regular expression that validate the email
     * address whether it contains an '@' signal and necessary characters.
     * 
     * @param s
     *            string to check
     * @return true if s is a valid email address
     */
    public static boolean isEmail(String s) {
        String regex = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(s + "");
        return m.matches();
    }
}

Related

  1. isEmail(String email)
  2. isEmail(String email)
  3. isEmail(String emailAddress)
  4. isEmail(String input)
  5. isEmail(String msg)
  6. isEmail(String str)
  7. isEmail(String str)
  8. isEmail(String str)
  9. isEmail(String str)