Here you can find the source of isLegalEmail(String email)
public static boolean isLegalEmail(String email)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isLegalEmail(String email) { String strPattern = "^[a-zA-Z0-9][a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]" + "@[a-zA-Z0-9][a-zA-Z0-9\\-_]*[a-zA-Z0-9]\\." + "([a-zA-Z0-9][a-zA-Z0-9\\-_]*[a-zA-Z0-9]\\.)*[a-zA-Z0-9]*$"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(email); return m.matches(); }//w ww. j av a2 s .c om }