X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FStringUtils.java;fp=src%2Fjalview%2Futil%2FStringUtils.java;h=efaf3e22fa0ed11f78e7f456be395cdefb7b4fed;hb=3303ad135025ac8b36ebb95f52d113a7b7df5444;hp=7e1b8ad2c86bcf0c82a585fb33defe63b9c94676;hpb=20d904c8e71db456b1a1cf1f80ff75f8bc42d245;p=jalview.git diff --git a/src/jalview/util/StringUtils.java b/src/jalview/util/StringUtils.java index 7e1b8ad..efaf3e2 100644 --- a/src/jalview/util/StringUtils.java +++ b/src/jalview/util/StringUtils.java @@ -600,6 +600,7 @@ public class StringUtils /* * implementation of String.replaceLast. + * Replaces only the last occurrence of toReplace in string with replacement. */ public static String replaceLast(String string, String toReplace, String replacement) @@ -607,8 +608,10 @@ public class StringUtils int pos = string.lastIndexOf(toReplace); if (pos > -1) { - return string.substring(0, pos) + replacement - + string.substring(pos + toReplace.length()); + return new StringBuilder().append(string.substring(0, pos)) + .append(replacement) + .append(string.substring(pos + toReplace.length())) + .toString(); } else {