class Const {

  @Deprecated
  public static String replEnv( String string ) {
    if ( string == null ) {
      return null;
    }
    StringBuilder str = new StringBuilder( string );

    int idx = str.indexOf( "%%" );
    while ( idx >= 0 ) {
      // OK, so we found a marker, look for the next one...
      int to = str.indexOf( "%%", idx + 2 );
      if ( to >= 0 ) {
        // OK, we found the other marker also...
        String marker = str.substring( idx, to + 2 );
        String var = str.substring( idx + 2, to );

        if ( var != null && var.length() > 0 ) {
          // Get the environment variable
          String newval = getEnvironmentVariable( var, null );

          if ( newval != null ) {
            // Replace the whole bunch
            str.replace( idx, to + 2, newval );

            // The last position has changed...
            to += newval.length() - marker.length();
          }
        }

      } else {
        // We found the start, but NOT the ending %% without closing %%
        to = idx;
      }

      // Look for the next variable to replace...
      idx = str.indexOf( "%%", to + 1 );
    }

    return str.toString();
  }

}