public static int indexOfAny(String str, String[] searchStrs) {
      if ((str == null) || (searchStrs == null)) {
          return -1;
      }
      int sz = searchStrs.length;

      // String's can't have a MAX_VALUEth index.
      int ret = Integer.MAX_VALUE;

      int tmp = 0;
      for (int i = 0; i < sz; i++) {
          String search = searchStrs[i];
          if (search == null) {
              continue;
          }
          tmp = str.indexOf(search);
          if (tmp == -1) {
              continue;
          }

          if (tmp < ret) {
              ret = tmp;
          }
      }

      return (ret == Integer.MAX_VALUE) ? -1 : ret;
  }
public static int indexOfAny ( String str , String [ ] searchStrs ) { if ( ( str == null ) || ( searchStrs == null ) ) { return - 1 ; } int sz = searchStrs . length ; int ret = Integer . MAX_VALUE ; int tmp = 0 ; for ( int i = 0 ; i < sz ; i ++ ) { String search = searchStrs [ i ] ; if ( search == null ) { continue ; } tmp = str . indexOf ( search ) ; if ( tmp == - 1 ) { continue ; } if ( tmp < ret ) { ret = tmp ; } } return ( ret == Integer . MAX_VALUE ) ? - 1 : ret ; }
<p>Find the first index of any of a set of potential substrings.</p>

<p>A <code>null</code> String will return <code>-1</code>.
A <code>null</code> or zero length search array will return <code>-1</code>.
A <code>null</code> search array entry will be ignored, but a search
array containing "" will return <code>0</code> if <code>str</code> is not
null. This method uses {@link String#indexOf(String)}.</p>

<pre>
GosuStringUtil.indexOfAny(null, *)                     = -1
GosuStringUtil.indexOfAny(*, null)                     = -1
GosuStringUtil.indexOfAny(*, [])                       = -1
GosuStringUtil.indexOfAny("zzabyycdxx", ["ab","cd"])   = 2
GosuStringUtil.indexOfAny("zzabyycdxx", ["cd","ab"])   = 2
GosuStringUtil.indexOfAny("zzabyycdxx", ["mn","op"])   = -1
GosuStringUtil.indexOfAny("zzabyycdxx", ["zab","aby"]) = 1
GosuStringUtil.indexOfAny("zzabyycdxx", [""])          = 0
GosuStringUtil.indexOfAny("", [""])                    = 0
GosuStringUtil.indexOfAny("", ["a"])                   = -1
</pre>

@param str  the String to check, may be null
@param searchStrs  the Strings to search for, may be null
@return the first index of any of the searchStrs in str, -1 if no match