用java代码实现判断输入的字符串是合法的电子邮箱地址
用java代码实现判断输入的字符串是合法的电子邮箱地址
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class CheckEmail {
?
?public static void main(String[] args) throws IOException {
??String reg = "\\w+[\\w]*@[\\w]+\\.[\\w]+$";
??BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
??while(true){
???System.out.println("请输入要验证的邮箱地址:"+"\n"+"-->");
???String input = reader.readLine();
???if(input.equals("q")||input.equals("exit")){
????System.exit(0);
???}
???if(input.matches(reg)){
????System.out.println("这是正确的邮箱地址");
???}else{
????System.out.println("这是错误的邮箱地址 ");
???}
??}
?}
}
怎麽看到帖子.......