src/main/java/org/jboss/util/Strings.java
/**
    * Count the number of instances of substring within a string.
    *
    * @param string     String to look for substring in.
    * @param substring  Sub-string to look for.
    * @return           Count of substrings in string.
    */
Count the number of instances of substring within a string.
@param string     String to look for substring in.
@param substring  Sub-string to look for.
@return           Count of substrings in string.
Count the number of instances of substring within a string . @param string String to look for substring in . @param substring Sub - string to look for . @return Count of substrings in string .
public static int count(final String string, final String substring)
   {
      int count = 0;
      int idx = 0;
      while ((idx = string.indexOf(substring, idx)) != -1)
      {
         idx++;
         count++;
      }
      return count;
   }
public static int count ( final String string , final String substring ) { int count = 0 ; int idx = 0 ; while ( ( idx = string . indexOf ( substring , idx ) ) != - 1 ) { idx ++ ; count ++ ; } return count ; }
Count the number of instances of substring within a string.
Count the number of instances of substring within a string .