Merge branch 'develop' into releases/Release_2_11_2_Branch
[jalview.git] / src / jalview / util / StringUtils.java
index bf5b87a..8b62e48 100644 (file)
@@ -413,7 +413,8 @@ public class StringUtils
     {
       return s.toUpperCase(Locale.ROOT);
     }
-    return s.substring(0, 1).toUpperCase(Locale.ROOT) + s.substring(1).toLowerCase(Locale.ROOT);
+    return s.substring(0, 1).toUpperCase(Locale.ROOT)
+            + s.substring(1).toLowerCase(Locale.ROOT);
   }
 
   /**
@@ -448,7 +449,7 @@ public class StringUtils
     {
       text = text.substring(0, endTag);
     }
-  
+
     if (startTag == -1 && (text.contains("<") || text.contains(">")))
     {
       text = text.replaceAll("<", "&lt;");
@@ -458,8 +459,8 @@ public class StringUtils
   }
 
   /**
-   * Answers the input string with any occurrences of the 'encodeable' characters
-   * replaced by their URL encoding
+   * Answers the input string with any occurrences of the 'encodeable'
+   * characters replaced by their URL encoding
    * 
    * @param s
    * @param encodable
@@ -570,4 +571,18 @@ public class StringUtils
     }
     return enc;
   }
+
+  public static int firstCharPosIgnoreCase(String text, String chars)
+  {
+    int min = text.length() + 1;
+    for (char c : chars.toLowerCase(Locale.ROOT).toCharArray())
+    {
+      int i = text.toLowerCase(Locale.ROOT).indexOf(c);
+      if (0 <= i && i < min)
+      {
+        min = i;
+      }
+    }
+    return min < text.length() + 1 ? min : -1;
+  }
 }