code: public String translate(String text, List<String[]> patterns) {
      String res = text;
  
      for (String[] each : patterns) {
        res = res.replaceAll("(?ms)" + each[0], each[1]);
      }
  
      return res;
    }
docs: Clone the python unicode translate method in legacy languages younger than python. python
  docutils is public domain.
  
  @param text
  string for which translation is needed
  @param patterns
  Array of arrays {target, replacement). The target is substituted by the replacement.
  @return The translated string
  @see http://docs.python.org/3/library/stdtypes.html#str.translate