cdm/src/main/java/ucar/unidata/util/StringUtil2.java
static public String unreplace(String x, String[] orgReplace, char[] orgChar) {
    // common case no replacement
    boolean ok = true;
    for (String anOrgReplace : orgReplace) {
      int pos = x.indexOf(anOrgReplace);
      ok = (pos < 0);
      if (!ok) break;
    }
    if (ok)
      return x;

    // gotta do it
    StringBuilder result = new StringBuilder(x);
    for (int i = 0; i < orgReplace.length; i++) {
      int pos = result.indexOf(orgReplace[i]);
      if (pos >= 0) {
        unreplace(result, orgReplace[i], orgChar[i]);
      }
    }

    return result.toString();
  }
static public String unreplace(String x, String[] orgReplace, char[] orgChar) {
    // common case no replacement
    boolean ok = true;
    for (String anOrgReplace : orgReplace) {
      int pos = x.indexOf(anOrgReplace);
      ok = (pos < 0);
      if (!ok) break;
    }
    if (ok)
      return x;

    // gotta do it
    StringBuilder result = new StringBuilder(x);
    for (int i = 0; i < orgReplace.length; i++) {
      int pos = result.indexOf(orgReplace[i]);
      if (pos >= 0) {
        unreplace(result, orgReplace[i], orgChar[i]);
      }
    }

    return result.toString();
  }
static public String unreplace ( String x , String [ ] orgReplace , char [ ] orgChar ) { // common case no replacement
 boolean ok = true ; for ( String anOrgReplace : orgReplace ) { int pos = x . indexOf ( anOrgReplace ) ; ok = ( pos < 0 ) ; if ( ! ok ) break ; } if ( ok ) return x ; // gotta do it
 StringBuilder result = new StringBuilder ( x ) ; for ( int i = 0 ; i < orgReplace . length ; i ++ ) { int pos = result . indexOf ( orgReplace [ i ] ) ; if ( pos >= 0 ) { unreplace ( result , orgReplace [ i ] , orgChar [ i ] ) ; } } return result . toString ( ) ; }
Replace all occurrences of orgReplace with orgChar; inverse of replace().

@param x          operate on this string
@param orgReplace get rid of these
@param orgChar    replace with these
@return resulting string
Replace all occurrences of orgReplace with orgChar ; inverse of replace () .