Here you can find the source of checkEmail(String email)
Parameter | Description |
---|---|
the email |
public static boolean checkEmail(String email)
//package com.java2s; /**/*from ww w .j a v a2 s. c o m*/ * Highlights words in a string. Words matching ignores case. The actual * higlighting method is specified with the start and end higlight tags. * Those might be beginning and ending HTML bold tags, or anything else. * <p> * * This method is under the Jive Open Source Software License and was * written by Mark Imbriaco. * * @param string * the String to highlight words in. * @return a new String with the specified words highlighted. */ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { /** * Check email. * * @param email * the email * @return true, if successful */ public static boolean checkEmail(String email) { String ps = "^([\\w-\\.]+)@[\\w-.]+(\\.?[a-zA-Z]{2,4}$)"; Pattern p = Pattern.compile(ps); Matcher m = p.matcher(email); if (m.matches()) { return true; } else { return false; } } }