String regex = "^A*C*B$"; Pattern p = Pattern.compile(regex); java.util.regex.Matcher m = p.matcher("这里是你要匹配的字符串"); while (m.find()) { System.out.println(m.group()); }