java正则表达式
2009-06-13 08:03 Iron 阅读(134) 评论(0) 编辑 收藏 举报import java.util.regex.*;
public class Main {
public static void main(String args[])
{
Pattern stringPattern = Pattern.compile("([0-9]{3})");
Matcher s = stringPattern.matcher("111");
System.out.println("phone:"+s.matches());
Pattern aPattern = Pattern.compile("[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-zA-Z0-9]+");
Matcher a = aPattern.matcher("hxf829@163.com");
System.out.println("email:"+a.matches());
}
}
public static void main(String args[])
{
Pattern stringPattern = Pattern.compile("([0-9]{3})");
Matcher s = stringPattern.matcher("111");
System.out.println("phone:"+s.matches());
Pattern aPattern = Pattern.compile("[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-zA-Z0-9]+");
Matcher a = aPattern.matcher("hxf829@163.com");
System.out.println("email:"+a.matches());
}
}