java正则表达式判断邮件地址是否合法
import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.Scanner; public class Email{ public static void main(String []args){ Scanner scan = new Scanner(System.in); String str=null; str = scan.next(); String pat="[a-zA-Z0-9_\\-\\.]+@[a-zA-Z0-9]+(\\.(com))"; Pattern p = Pattern.compile(pat);//实例化Pattern类 Matcher m = p.matcher(str);//验证内容是否合法 if(m.matches()) System.out.println("YES"); else System.out.println("NO"); } }