title: python+postgresql: Convert string literal to regex
body: <p>I want to execute a query where I match a column name using a regex to my variable, <code>s</code>. <code>s</code> is a string literal and may contain things like <code>?</code>, <code>*</code>, <code>.</code>, etc. I want to convert <code>s</code> so that <code>?</code> turns into <code>.{0,3}</code>, so that all of its remaining regex symbols remain literals, and then add <code>.*</code> to the end. examples:</p>
  
  <pre><code>Hi -&gt; Hi.*
  Fo?ar -&gt; Fo.{0,3}ar.*
  F.a*rx -&gt; F\.a\*rx.*
  F.a?*rx -&gt; F\.a.{0,3}\*rx
  </code></pre>
  
  <p>What's the best way to do this? Mostly I'm unsure how to quote a string literal so the regex symbols aren't interpreted as regex symbols (e.g. <code>.</code> -> <code>\.</code>).</p>