JAL-629 PAE matrix file guesstimate from filename
[jalview.git] / src / jalview / util / StringUtils.java
index adba947..7e1b8ad 100644 (file)
@@ -597,4 +597,23 @@ public class StringUtils
     }
     return index;
   }
+
+  /*
+   * implementation of String.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());
+    }
+    else
+    {
+      return string;
+    }
+  }
+
 }