+ // Rewritten to not use regex for Jalviewjs. Probably more efficient this
+ // way anyway.
+ if (text == null)
+ {
+ return -1;
+ }
+ for (int i = 0; i < text.length(); i++)
+ {
+ if (Character.isWhitespace(text.charAt(i)))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /*
+ * 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)
+ {
+ int pos = string.lastIndexOf(toReplace);
+ if (pos > -1)
+ {
+ return new StringBuilder().append(string.substring(0, pos))
+ .append(replacement)
+ .append(string.substring(pos + toReplace.length()))
+ .toString();
+ }
+ else
+ {
+ return string;
+ }
+
+ }
+
+ /*
+ * return the maximum length of a List of Strings
+ */
+ public static int maxLength(List<String> l)
+ {
+ int max = 0;
+ for (String s : l)