title: extract substring regex using printf syntax
body: <p>I'm a big fan of using the <code>%</code> (modulo / string formatting operator thingy), for example:</p>
  
  <pre><code>&gt;&gt;&gt; fileName = "par1-%d_par2-%.1f_%s.dat" % (par1, par2, suffix)
  par1-5_par2-0.1_hello.dat
  </code></pre>
  
  <p>Is there any package/function which allows you to reverse this process to extract the regex patterns from the string?  e.g.</p>
  
  <pre><code>&gt;&gt;&gt; magicFunction(fileName, "par1-%d_par2-%.1f_%s.dat")
  1, 0.1, 'hello'
  </code></pre>