package com.test;
import java.util.regex.Matcher; //导包
import java.util.regex.Pattern; //导包
public class StringTest {
public static void main(String[] args) {
Pattern p = Pattern.compile("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.([a-zA-Z0-9_-])+)+$"); //正则表达式
Matcher m = p.matcher("wanhui@email.com");
//Mather m = p.matcher("wanhui1999@email.com.cn");这种也是可以的!
boolean b = m.matches();
System.out.print(b);//true
}
}