Pattern p = Pattern.compile("a*b");//正则表达式 Matcher m = p.matcher("aaaaab");//匹配的字符串 boolean b = m.matches(); //等价于: boolean b2 = Pattern.matches("a*b", "aaaaab");