Environment variables support

Issue #483 invalid
Pierre-Luc Veilleux created an issue

using this technique : https://bitbucket.org/asomov/snakeyaml/wiki/Variable substitution

I can substitute environment VAR with value

var: ${VAR-test}

But I cannot with

var: Value before ${VAR-test}

Even with specifying null as “first”

yaml.addImplicitResolver(EnvScalarConstructor.ENV_TAG, EnvScalarConstructor.ENV_FORMAT, null)

because ENV_FORMAT pattern is matching the start of line followed by $

public static final Pattern ENV_FORMAT = Pattern.compile("^\\$\\{\\s*((?<name>\\w+)((?<separator>:?(-|\\?))(?<value>\\w+)?)?)\\s*\\}$");

Comments (2)

  1. Andrey Somov

    The documentation from the link you provided explicitly says:

    Since SnakeYAML is no template engine, it does not substitute parts of scalar,

    If you think it can be improved - the pull request is welcome !

  2. Log in to comment