Skip to content

Commit

Permalink
add CoreUtilities.indexOfAny
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 12, 2020
1 parent eeaa0b1 commit fdbb34d
Showing 1 changed file with 11 additions and 0 deletions.
Expand Up @@ -596,6 +596,17 @@ public static String getClosestOption(List<String> strs, String opt) {
return closest;
}

public static int indexOfAny(String str, int start, char... chars) {
int earliest = -1;
for (char c : chars) {
int index = str.indexOf(c, start);
if (index != -1 && (earliest == -1 || index < earliest)) {
earliest = index;
}
}
return earliest;
}

public static int getLevenshteinDistance(String s, String t) {
if (s == null || t == null) {
throw new IllegalArgumentException("Strings must not be null");
Expand Down

0 comments on commit fdbb34d

Please sign in to comment.