title: Python replace middle digits with commas thousand separator
body: <p>I have a string like this:</p>
  
  <pre><code>123456789.123456789-123456789
  </code></pre>
  
  <p>Before and after the decimal/hyphen there can be any number of digits, what I need to do is remove everything before the decimal including the decimal and remove the hyphen and everything after the hyphen. Then with the middle group of digits (that I need to keep) I need to place a comma thousands separators. </p>
  
  <p>So here the output would be: </p>
  
  <pre><code>123,456,789
  </code></pre>
  
  <p>I can use lookarounds to capture the digits in the middle but then it wont replace the other digits and i'm not sure how to place commas using lookarounds. </p>
  
  <pre><code>(?&lt;=\.)\d+(?=-)
  </code></pre>
  
  <p>Then I figured I could use a capturing group like so which will work, but not sure how to insert the comma's</p>
  
  <pre><code>\d+\.(\d+)-\d+
  </code></pre>
  
  <p>How could I insert comma's using one of the above regex? </p>