public static String replace()

in src/main/java/org/apache/maven/shared/utils/StringUtils.java [698:715]


    public static String replace(@Nullable String text, @Nullable String repl, @Nullable String with, int max) {
        if ((text == null) || (repl == null) || (with == null) || (repl.length() == 0)) {
            return text;
        }

        StringBuilder buf = new StringBuilder(text.length());
        int start = 0, end;
        while ((end = text.indexOf(repl, start)) != -1) {
            buf.append(text, start, end).append(with);
            start = end + repl.length();

            if (--max == 0) {
                break;
            }
        }
        buf.append(text, start, text.length());
        return buf.toString();
    }