@Test public void testMustacheTagPattern() { String text = "{{foo }} and {{#bar}}...{{/bar}}"; Pattern tagPattern = Patterns .newMustacheTagPattern(MustacheEngineBuilder.newBuilder() .build().getConfiguration()); Matcher matcher = tagPattern.matcher(text); StringBuffer result = new StringBuffer(); int occurences = 0; while (matcher.find()) { System.out.println(matcher.group(0)); matcher.appendReplacement(result, "FOUND"); occurences++; } matcher.appendTail(result); assertEquals(3, occurences); assertEquals("FOUND and FOUND...FOUND", result.toString()); }
public static Pattern newMustacheTagPattern(Configuration configuration) { StringBuilder regex = new StringBuilder(); regex.append(Pattern.quote(configuration .getStringPropertyValue(EngineConfigurationKey.START_DELIMITER))); regex.append(".*?"); regex.append(Pattern.quote(configuration .getStringPropertyValue(EngineConfigurationKey.END_DELIMITER))); return Pattern.compile(regex.toString()); }
Patterns { public static Pattern newMustacheTagPattern(Configuration configuration) { StringBuilder regex = new StringBuilder(); regex.append(Pattern.quote(configuration .getStringPropertyValue(EngineConfigurationKey.START_DELIMITER))); regex.append(".*?"); regex.append(Pattern.quote(configuration .getStringPropertyValue(EngineConfigurationKey.END_DELIMITER))); return Pattern.compile(regex.toString()); } }
Patterns { public static Pattern newMustacheTagPattern(Configuration configuration) { StringBuilder regex = new StringBuilder(); regex.append(Pattern.quote(configuration .getStringPropertyValue(EngineConfigurationKey.START_DELIMITER))); regex.append(".*?"); regex.append(Pattern.quote(configuration .getStringPropertyValue(EngineConfigurationKey.END_DELIMITER))); return Pattern.compile(regex.toString()); } private  Patterns(); }
Patterns { public static Pattern newMustacheTagPattern(Configuration configuration) { StringBuilder regex = new StringBuilder(); regex.append(Pattern.quote(configuration .getStringPropertyValue(EngineConfigurationKey.START_DELIMITER))); regex.append(".*?"); regex.append(Pattern.quote(configuration .getStringPropertyValue(EngineConfigurationKey.END_DELIMITER))); return Pattern.compile(regex.toString()); } private  Patterns(); static Pattern newMustacheTagPattern(Configuration configuration); static Pattern newSetDelimitersContentPattern(); static Pattern newHelperIntegerLiteralPattern(); static Pattern newHelperLongLiteralPattern(); }
Patterns { public static Pattern newMustacheTagPattern(Configuration configuration) { StringBuilder regex = new StringBuilder(); regex.append(Pattern.quote(configuration .getStringPropertyValue(EngineConfigurationKey.START_DELIMITER))); regex.append(".*?"); regex.append(Pattern.quote(configuration .getStringPropertyValue(EngineConfigurationKey.END_DELIMITER))); return Pattern.compile(regex.toString()); } private  Patterns(); static Pattern newMustacheTagPattern(Configuration configuration); static Pattern newSetDelimitersContentPattern(); static Pattern newHelperIntegerLiteralPattern(); static Pattern newHelperLongLiteralPattern();  }