cdm/src/main/java/ucar/unidata/util/StringUtil2.java
static public String substitute(String original, String[] match, String[] subst) {

    boolean ok = true;
    for (String aMatch : match) {
      if (original.contains(aMatch)) {
        ok = false;
        break;
      }
    }
    if (ok) {
      return original;
    }

    // gotta do it;
    StringBuilder sb = new StringBuilder(original);
    for (int i = 0; i < match.length; i++) {
      substitute(sb, match[i], subst[i]);
    }
    return sb.toString();
  }
static public String substitute(String original, String[] match, String[] subst) {

    boolean ok = true;
    for (String aMatch : match) {
      if (original.contains(aMatch)) {
        ok = false;
        break;
      }
    }
    if (ok) {
      return original;
    }

    // gotta do it;
    StringBuilder sb = new StringBuilder(original);
    for (int i = 0; i < match.length; i++) {
      substitute(sb, match[i], subst[i]);
    }
    return sb.toString();
  }
static public String substitute ( String original , String [ ] match , String [ ] subst ) { boolean ok = true ; for ( String aMatch : match ) { if ( original . contains ( aMatch ) ) { ok = false ; break ; } } if ( ok ) { return original ; } // gotta do it;
 StringBuilder sb = new StringBuilder ( original ) ; for ( int i = 0 ; i < match . length ; i ++ ) { substitute ( sb , match [ i ] , subst [ i ] ) ; } return sb . toString ( ) ; }
Find all occurences of match strings in original, and substitute the corresponding
subst string.

@param original starting string
@param match    array of strings to match
@param subst    array of strings to substitute
@return a new string with substitutions
Find all occurences of match strings in original and substitute the corresponding subst string .