@@ -2708,54 +2708,6 @@ public static int indexOfAny(final CharSequence cs, final char... searchChars) {
27082708 return indexOfAny (cs , 0 , searchChars );
27092709 }
27102710
2711- /**
2712- * Search a CharSequence to find the first index of any character in the given set of characters.
2713- *
2714- * <p>
2715- * A {@code null} String will return {@code -1}. A {@code null} or zero length search array will return {@code -1}.
2716- * </p>
2717- * <p>
2718- * The following is the same as {@code indexOfAny(cs, 0, searchChars)}.
2719- * </p>
2720- * <pre>
2721- * StringUtils.indexOfAny(null, 0, *) = -1
2722- * StringUtils.indexOfAny("", 0, *) = -1
2723- * StringUtils.indexOfAny(*, 0, null) = -1
2724- * StringUtils.indexOfAny(*, 0, []) = -1
2725- * StringUtils.indexOfAny("zzabyycdxx", 0, ['z', 'a']) = 0
2726- * StringUtils.indexOfAny("zzabyycdxx", 0, ['b', 'y']) = 3
2727- * StringUtils.indexOfAny("aba", 0, ['z']) = -1
2728- * </pre>
2729- *
2730- * @param cs the CharSequence to check, may be null.
2731- * @param csStart Start searching the input {@code cs} at this index.
2732- * @param searchChars the chars to search for, may be null.
2733- * @return the index of any of the chars, -1 if no match or null input.
2734- * @since 2.0
2735- * @since 3.0 Changed signature from indexOfAny(String, char[]) to indexOfAny(CharSequence, char...)
2736- */
2737- public static int indexOfAny (final CharSequence cs , final int csStart , final char ... searchChars ) {
2738- if (isEmpty (cs ) || ArrayUtils .isEmpty (searchChars )) {
2739- return INDEX_NOT_FOUND ;
2740- }
2741- final int csLen = cs .length ();
2742- final int csLast = csLen - 1 ;
2743- final int searchLen = searchChars .length ;
2744- final int searchLast = searchLen - 1 ;
2745- for (int i = csStart ; i < csLen ; i ++) {
2746- final char ch = cs .charAt (i );
2747- for (int j = 0 ; j < searchLen ; j ++) {
2748- if (searchChars [j ] == ch ) {
2749- // ch is a supplementary character
2750- if (i >= csLast || j >= searchLast || !Character .isHighSurrogate (ch ) || searchChars [j + 1 ] == cs .charAt (i + 1 )) {
2751- return i ;
2752- }
2753- }
2754- }
2755- }
2756- return INDEX_NOT_FOUND ;
2757- }
2758-
27592711 /**
27602712 * Find the first index of any of a set of potential substrings.
27612713 *
@@ -2805,6 +2757,54 @@ public static int indexOfAny(final CharSequence str, final CharSequence... searc
28052757 return ret == Integer .MAX_VALUE ? INDEX_NOT_FOUND : ret ;
28062758 }
28072759
2760+ /**
2761+ * Search a CharSequence to find the first index of any character in the given set of characters.
2762+ *
2763+ * <p>
2764+ * A {@code null} String will return {@code -1}. A {@code null} or zero length search array will return {@code -1}.
2765+ * </p>
2766+ * <p>
2767+ * The following is the same as {@code indexOfAny(cs, 0, searchChars)}.
2768+ * </p>
2769+ * <pre>
2770+ * StringUtils.indexOfAny(null, 0, *) = -1
2771+ * StringUtils.indexOfAny("", 0, *) = -1
2772+ * StringUtils.indexOfAny(*, 0, null) = -1
2773+ * StringUtils.indexOfAny(*, 0, []) = -1
2774+ * StringUtils.indexOfAny("zzabyycdxx", 0, ['z', 'a']) = 0
2775+ * StringUtils.indexOfAny("zzabyycdxx", 0, ['b', 'y']) = 3
2776+ * StringUtils.indexOfAny("aba", 0, ['z']) = -1
2777+ * </pre>
2778+ *
2779+ * @param cs the CharSequence to check, may be null.
2780+ * @param csStart Start searching the input {@code cs} at this index.
2781+ * @param searchChars the chars to search for, may be null.
2782+ * @return the index of any of the chars, -1 if no match or null input.
2783+ * @since 2.0
2784+ * @since 3.0 Changed signature from indexOfAny(String, char[]) to indexOfAny(CharSequence, char...)
2785+ */
2786+ public static int indexOfAny (final CharSequence cs , final int csStart , final char ... searchChars ) {
2787+ if (isEmpty (cs ) || ArrayUtils .isEmpty (searchChars )) {
2788+ return INDEX_NOT_FOUND ;
2789+ }
2790+ final int csLen = cs .length ();
2791+ final int csLast = csLen - 1 ;
2792+ final int searchLen = searchChars .length ;
2793+ final int searchLast = searchLen - 1 ;
2794+ for (int i = csStart ; i < csLen ; i ++) {
2795+ final char ch = cs .charAt (i );
2796+ for (int j = 0 ; j < searchLen ; j ++) {
2797+ if (searchChars [j ] == ch ) {
2798+ // ch is a supplementary character
2799+ if (i >= csLast || j >= searchLast || !Character .isHighSurrogate (ch ) || searchChars [j + 1 ] == cs .charAt (i + 1 )) {
2800+ return i ;
2801+ }
2802+ }
2803+ }
2804+ }
2805+ return INDEX_NOT_FOUND ;
2806+ }
2807+
28082808 /**
28092809 * Search a CharSequence to find the first index of any character in the given set of characters.
28102810 *
0 commit comments