title: Truncating string with re.sub
body: <p>I have a url stored as <code>type=str</code>. Looks like this: </p>
  
  <pre><code>url = 'http://www.dog.com/bone?junk=8dj37hf7'
  </code></pre>
  
  <p>I want to delete all chars beginning with '?', so I would have:</p>
  
  <pre><code>url = 'http://www.dog.com/bone'
  </code></pre>
  
  <p>This is what I've tried: </p>
  
  <pre><code>import re
  re.sub('?junk=*', '', url)
  </code></pre>
  
  <p>But I get this error: </p>
  
  <blockquote>
    <blockquote>
      <blockquote>
        <p>raise error, v # invalid expression
        sre_constants.error: nothing to repeat</p>
      </blockquote>
    </blockquote>
  </blockquote>
  
  <p>This is the solution: </p>
  
  <pre><code>import re
  re.sub('\?junk=.*', '', url)
  </code></pre>
  
  <hr>
  
  <p>Edited to insert code bracketing. 
  Edited to add .* notation per 
  Morten Jensen, but the error persists. </p>
  
  <p>Edit: Solved with '.*' and '\' escape. Thanks to Morten Jensen, jwodder, thefourtheye, et al. </p>