Here you can find the source of isEmail(String s)
Parameter | Description |
---|---|
s | string to check |
public static boolean isEmail(String s)
//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(); } }