Github user garydgregory commented on a diff in the pull request: https://github.com/apache/commons-lang/pull/273#discussion_r161278687 --- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java --- @@ -2122,6 +2122,81 @@ public static int indexOfAny(final CharSequence cs, final String searchChars) { return indexOfAny(cs, searchChars.toCharArray()); } + /** + * <p>Search a CharSequence to find the last index of any + * character in the given set of characters.</p> + * + * <p>A {@code null} String will return {@code -1}. + * A {@code null} search string will return {@code -1}.</p> + * + * <pre> + * StringUtils.lastIndexOfAnyChar(null, *) = -1 + * StringUtils.lastIndexOfAnyChar("", *) = -1 + * StringUtils.lastIndexOfAnyChar(*, null) = -1 + * StringUtils.lastIndexOfAnyChar(*, "") = -1 + * StringUtils.lastIndexOfAnyChar("zzabyycdxx", "za") = 2 + * StringUtils.lastIndexOfAnyChar("zzabyycdxx", "by") = 5 + * StringUtils.lastIndexOfAnyChar("ab", 'a') = 0 + * StringUtils.lastIndexOfAnyChar("ab", 'b') = 1 + * StringUtils.lastIndexOfAnyChar("aba","z") = -1 + * </pre> + * + * @param cs the CharSequence to check, may be null + * @param searchChars the chars to search for, may be null + * @return the last index of any of the chars, -1 if no match or null input + */ + public static int lastIndexOfAnyChar( final CharSequence cs,final String searchChars) { + return searchChars == null ? INDEX_NOT_FOUND : lastIndexOfAnyChar(cs,searchChars.toCharArray()); + } + + /** + * <p>Search a CharSequence to find the last index of any + * character in the given set of characters.</p> + * + * <p>A {@code null} String will return {@code -1}. + * A {@code null} or zero length search array will return {@code -1}.</p> + * + * <pre> + * StringUtils.lastIndexOfAnyChar(null, *) = -1 + * StringUtils.lastIndexOfAnyChar("", *) = -1 + * StringUtils.lastIndexOfAnyChar(*, null) = -1 + * StringUtils.lastIndexOfAnyChar(*, []) = -1 + * StringUtils.lastIndexOfAnyChar("zzabyycdxx",['z','a']) = 2 + * StringUtils.lastIndexOfAnyChar("zzabyycdxx",['b','y']) = 5 + * StringUtils.lastIndexOfAnyChar("aba", ['z']) = -1 + * </pre> + * + * @param cs the CharSequence to check, may be null + * @param searchChars the chars to search for, may be null + * @return the last index of any of the chars, -1 if no match or null input + */ + public static int lastIndexOfAnyChar( final CharSequence cs,final char... searchChars) { --- End diff -- Fix formatting.
---