JAL-1655 JAL-845 special support to set column width of protein panel 3*width of...
[jalview.git] / src / jalview / util / StringUtils.java
index c1e050f..0544864 100644 (file)
@@ -1,5 +1,6 @@
 package jalview.util;
 
+
 public class StringUtils
 {
 
@@ -79,4 +80,27 @@ public class StringUtils
     }
     return tmp;
   }
+
+  /**
+   * Returns the last part of 'input' after the last occurrence of 'token'. For
+   * example to extract only the filename from a full path or URL.
+   * 
+   * @param input
+   * @param token
+   *          a delimiter which must be in regular expression format
+   * @return
+   */
+  public static String getLastToken(String input, String token)
+  {
+    if (input == null)
+    {
+      return null;
+    }
+    if (token == null)
+    {
+      return input;
+    }
+    String[] st = input.split(token);
+    return st[st.length - 1];
+  }
 }