How do I get lua string match to parse an environment variable string?
snippet in lua

How do I get lua string match to parse an environment variable string?

user4975

local text = [[
Example: ${LANG}, $TEXTDOMAINDIR, $$10.00, $$LANG, $UNDEFINED
Nested braces: {{${SHELL}}}
]]
text = text:gsub('$%$','\0')
           :gsub('${([%w_]+)}', os.getenv)
           :gsub('$([%w_]+)', os.getenv)
           :gsub('%z','$')
print(text)
--> Example: en_US.UTF-8, /usr/share/locale/, $10.00, $LANG, $UNDEFINED
--> Nested braces: {{/bin/bash}}