Generate values for str.format style template strings from formatted output
<p>This might seem like a wierd requirement, but I am looking for a good implementation to do this.</p>

<p>I have a dict like</p>

<pre><code>vals = dict(red='#F00', green='#0F0', blue='#00F')
</code></pre>

<p>and a string like</p>

<pre><code>tpl = '{red}:{green}:{blue}'
</code></pre>

<p>and the <code>str.format</code>ted output</p>

<pre><code>output = tpl.format(**vals)
</code></pre>

<p>All is well till here. However, I now need to do the reverse of this. I have to turn a string like <code>'#F00:#0F0:#00F'</code> into a dict of the values that we previously started with. Of course, I could just <code>split</code> and <code>strip</code> the string and take the values I need, but it will fail in the event the <code>tpl</code> string should change.</p>

<p>Any good ideas on how I can do this (If it can even be done, that is)?</p>
