Bootstrap

java replaceLast

替换最后一个特定字符

public static String replaceLast(String string, String toReplace, String replacement) {
    int pos = string.lastIndexOf(toReplace);
    if (pos > -1) {
        return string.substring(0, pos)
                + replacement
                + string.substring(pos + toReplace.length(), string.length());
    } else {
        return string;
    }
}
;