docs: public static String replaceAll(final String input, final Pattern regex,
        final Function<MatchResult, String> replacementFunction) {
      final StringBuffer output = new StringBuffer();
      final Matcher matcher = regex.matcher(input);
      while (matcher.find()) {
        final MatchResult match = matcher.toMatchResult();
        final String replacement = replacementFunction.apply(match);
        if (replacement == null) {
          throw new IllegalArgumentException(
              String.format("Replacement function returned null for match %s", match.group()));
        }
        if (!replacement.equals(match.group())) {
          matcher.appendReplacement(output, replacement);
        }
      }
      matcher.appendTail(output);
      return output.toString();
    }