code: public static String expandEnvironmentVariables(final String command) {
  
      final Matcher match = ENV_REGEX.matcher(command);
      final StringBuilder res = new StringBuilder(command.length());
  
      int i = 0;
      while (match.find()) {
        final String var = System.getenv(match.group(1));
        res.append(command.substring(i, match.start())).append(var == null ? "" : var);
        i = match.end();
      }
  
      return res.append(command.substring(i, command.length())).toString();
    }
docs: Replace {{ENV_VAR}} placeholders with the values of the corresponding environment variables.
  @param command An input string with {{ENV_VAR}} placeholders
  to be replaced with the values of the corresponding environment variables.
  Replace unknown/unset variables with an empty string.
  @return A new string with all the placeholders expanded.