Pattern pattern = Pattern.compile("\\$page\\{(.*?)\\}");
Matcher matcher = pattern.matcher(source);
StringBuffer sbr = new StringBuffer();
while (matcher.find()) {
String mate1 =
addPage(matcher.group(1));
matcher.appendReplacement(sbr,mate1);
}
matcher.appendTail(sbr);
System.out.println(sbr.toString());
return sbr.toString();
// String patternString = "\\$page\\{(.*?)\\}";//勉强匹配
// Pattern pattern = null;
// try {
// pattern = Pattern.compile(patternString);
// Matcher matcher = pattern.matcher(source);
// while (matcher.find()) {
// String mate = matcher.group(0);
// String mate1 = matcher.group(1);
// source = source.replace(mate, this.addPage(mate1));
// matcher.reset(source);
// }
// } catch (PatternSyntaxException e) {
// e.printStackTrace();
// throw new Exception(e);
// }
// return source;