private static void EnvVariableSubstitution(JToken item, IConfigVariables enviromentVariables) { if (item?.Type != JTokenType.String) { return; } var val = item.Value <string>(); if (_envVariableRegex.IsMatch(val)) { foreach (Match match in _envVariableRegex.Matches(val)) { if (match != null) { var envName = match.Groups[0].Value; var envValue = enviromentVariables.GetEnviromentVariable(match.Groups[1].Value); val = val.Replace(envName, envValue); } } item.Replace(JToken.FromObject(val)); } }