title: Python regex replace whole string
body: <p>I have a regex to strip the end off a request url:</p>
  
  <pre><code>re.sub('(?:^\/en\/category).*(-\d{1,4}$)', '', r)
  </code></pre>
  
  <p>My problem is that the docs say it will replace the matched part, however when it matches my string it replaces the <strong>whole string</strong>, e.g.:</p>
  
  <pre><code>/en/category/specials/men-2610
  </code></pre>
  
  <p>I'm not sure what Python is doing, but <a href="https://regex101.com/r/dZ1pU2/1" rel="nofollow">my regex seems fine</a></p>
  
  <p><em>EDIT</em>: I wish to have the string with the end stripped off, target = </p>
  
  <pre><code>/en/category/specials/men
  </code></pre>