code: public static String gsub(String word, String rule, String replacement) {
          Pattern pattern = Pattern.compile(rule, Pattern.CASE_INSENSITIVE);
          Matcher matcher = pattern.matcher(word);
          return matcher.find() ? matcher.replaceFirst(replacement) : null;
      }
docs: Replaces a found pattern in a word and returns a transformed word.
  @param word
  @param rule
  @param replacement
  @return Replaces a found pattern in a word and returns a transformed word. Null is pattern does not match.