title: How to use re.sub in Python
body: <p>Please help me replace a particular string with re.sub()</p>
  <pre><code>'&lt;a href=&quot;/abc-10063/&quot; target=&quot;_blank&quot;&gt;'
  </code></pre>
  <p>needs to be</p>
  <pre><code>'&lt;a href=&quot;./abc-10063.html&quot; target=&quot;_blank&quot;&gt;'
  </code></pre>
  <p>Wrote a script below</p>
  <pre><code>import re
  test = '&lt;a href=&quot;/abcd-10063/&quot; target=&quot;_blank&quot;&gt;'
  print(re.sub(r'/abcd-[0-9]','./abcd-[0-9].html', test))
  </code></pre>
  <p>which returns</p>
  <pre><code>&lt;a href=&quot;./abcd-[0-9].html0063/&quot; target=&quot;_blank&quot;&gt;
  </code></pre>