I have a string that contains an arbitrary number of inserts in the form of variables names that will be in the global namespace. Please note the future tense - the variables do not yet exist at the moment when the formatted string is created.
txt = "{x} --- {y}" # could very well be "{z} --- {x} --- {w}"
x = "A"
y = "B"
When the string needs to be evaluated (and all variables exist), I need to specify each of the inserts by name. However, since it doesn't use the same variables each time, the only way is to parse the string and extract the variable names