String replaceSuffix(String from, String to) { if (endsWith(from)) { return replaceRange(length - from.length, null, to); } else { return this; } }