cdm/src/main/java/ucar/unidata/util/StringUtil2.java
static public void substitute(StringBuilder sbuff, String match, String subst) {
    int pos, fromIndex = 0;
    int substLen = subst.length();
    int matchLen = match.length();
    while (0 <= (pos = sbuff.indexOf(match, fromIndex))) {
      sbuff.replace(pos, pos + matchLen, subst);
      fromIndex = pos + substLen;  // make sure dont get into an infinite loop
    }
  }
static public void substitute(StringBuilder sbuff, String match, String subst) {
    int pos, fromIndex = 0;
    int substLen = subst.length();
    int matchLen = match.length();
    while (0 <= (pos = sbuff.indexOf(match, fromIndex))) {
      sbuff.replace(pos, pos + matchLen, subst);
      fromIndex = pos + substLen;  // make sure dont get into an infinite loop
    }
  }
static public void substitute ( StringBuilder sbuff , String match , String subst ) { int pos , fromIndex = 0 ; int substLen = subst . length ( ) ; int matchLen = match . length ( ) ; while ( 0 <= ( pos = sbuff . indexOf ( match , fromIndex ) ) ) { sbuff . replace ( pos , pos + matchLen , subst ) ; fromIndex = pos + substLen ; // make sure dont get into an infinite loop
 } }
Find all occurences of the "match" in original, and substitute the "subst" string,
directly into the original.

@param sbuff starting string buffer
@param match string to match
@param subst string to substitute
Find all occurences of the match in original and substitute the subst string directly into the original .