src/main/java/org/jboss/util/Strings.java
/**
    * Substitute sub-strings in side of a string.
    *
    * @param buff    Stirng buffer to use for substitution (buffer is not reset)
    * @param from    String to substitute from
    * @param to      String to substitute to
    * @param string  String to look for from in
    * @return        Substituted string
    */
Substitute sub-strings in side of a string.
Substitute sub - strings in side of a string .
public static String subst(final StringBuffer buff, final String from,
      final String to, final String string)
   {
      int begin = 0, end = 0;
      while ((end = string.indexOf(from, end)) != -1)
      {
         buff.append(string.substring(begin, end));
         buff.append(to);
         begin = end + from.length();
         end = begin;
      }
      buff.append(string.substring(begin, string.length()));
      return buff.toString();
   }
public static String subst ( final StringBuffer buff , final String from , final String to , final String string ) { int begin = 0 , end = 0 ; while ( ( end = string . indexOf ( from , end ) ) != - 1 ) { buff . append ( string . substring ( begin , end ) ) ; buff . append ( to ) ; begin = end + from . length ( ) ; end = begin ; } buff . append ( string . substring ( begin , string . length ( ) ) ) ; return buff . toString ( ) ; }
Substitute sub-strings in side of a string.
Substitute sub - strings in side of a string .
// append the first part of the string // append the replaced string // update positions // append the rest of the string