import java.io.*;
import java.util.regex.*;
public class test{
public static void main(String[] args){
try{
String s = "";
while(!s.equals("q")){
System.out.print("input:");
DataInputStream in = new DataInputStream(new BufferedInputStream(System.in));
s = in.readLine();
System.out.println("your input is :"+s);
String check = "^([a-z0-9A-Z]+[-|\\._]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
Pattern regex = Pattern.compile(check);
Matcher matcher = regex.matcher(s);
boolean isMatched = matcher.matches();
if(isMatched){
System.out.println("it's a email");
}else{
System.out.println("it's not a email");
}
}
}catch(Exception e){
System.out.println("error"+e.getMessage());
}
}
}
posted on 2005-04-16 14:02
Stephen 阅读(719)
评论(0) 编辑 收藏 所属分类:
Java