public static int countIgnoreCase(String source,String sub){
  int count=0;
  int j=0;
  int sublen=sub.length();
  if (sublen == 0) {
    return 0;
  }
  while (true) {
    int i=indexOfIgnoreCase(source,sub,j);
    if (i == -1) {
      break;
    }
    count++;
    j=i + sublen;
  }
  return count;
}

public static int countIgnoreCase ( String source , String sub ) { int count = 0 ; int j = 0 ; int sublen = sub . length ( ) ; if ( sublen == 0 ) { return 0 ; } while ( true ) { int i = indexOfIgnoreCase ( source , sub , j ) ; if ( i == - 1 ) { break ; } count ++ ; j = i + sublen ; } return count ; }
count substring occurrences in a source string , ignoring case .
