parsing any arbitrary code is probably not a good idea
what about using a Dict
and replace
:
vars = Dict("me" => "Sam", "you" => "Max")
str = "I am \$me"
for (var, val) in vars
str = replace(str, "\$"*var => val)
end
although this would cause problems if a variable name contains another variable name (eg if you have $me
and $metoo
)