public String encodedContents(String contents){
  String reg="M.e\\(\"((?:\"|.)*?)\"\\)";
  Pattern p=Pattern.compile(reg,Pattern.MULTILINE);
  Matcher m=p.matcher(contents);
  StringBuffer sb=new StringBuffer();
  while (m.find()) {
    String text=m.group(1);
    m.appendReplacement(sb,polymorph(text));
  }
  m.appendTail(sb);
  return sb.toString();
}

public String encodedContents ( String contents ) { String reg = "M.e\\(\"((?:\"|.)*?)\"\\)" ; Pattern p = Pattern . compile ( reg , Pattern . MULTILINE ) ; Matcher m = p . matcher ( contents ) ; StringBuffer sb = new StringBuffer ( ) ; while ( m . find ( ) ) { String text = m . group ( 1 ) ; m . appendReplacement ( sb , polymorph ( text ) ) ; } m . appendTail ( sb ) ; return sb . toString ( ) ; }
encoda un contenuto , riconoscendo il pattern di una stringa . ogni stringa viene caricata in una lista , che poi viene usata per la generazione di m . java
