@Test
public void testApplyWithConsecutiveDollars() throws Exception {

  System.setProperty("config.file", "src/test/resources/test.conf");
  ConfigFactory.invalidateCaches();
  final Config config = ConfigFactory.load();
  final String sessionId = "test";
  String regex = "\\b([\\w.%-]+)(@[-.\\w]+\\.[A-Za-z]{2,4})\\b";
  String replacement = "\\$Email$2$1";
  RegexTokenAnnotator filter = new RegexTokenAnnotator(regex, replacement, null, sessionId);
  Sentence text = new Sentence("My address is joe.schmoe@test.com.", sessionId);
  filter.annotate(text);
  List<Annotation<TokenPlaceholder>> placeholders = text.getAnnotations(TokenPlaceholder.class);
  LOG.debug(placeholders.toString());
  assertEquals(1, placeholders.size());
  Annotation<TokenPlaceholder> placeholder = placeholders.get(0);
  assertEquals(14, placeholder.getStart());
  assertEquals(33, placeholder.getEnd());
  assertEquals("$Email@test.comjoe.schmoe", placeholder.getData().getReplacement());
}