Pattern p = Pattern.compile("a*b"); Matcher m = p.matcher("abcdefgb"); boolean b = m.matches(); //快速用法 boolean b = Pattern.matches("a*b", "abcdefgb");