title: Removing Trailing White Spaces with python
body: <p>I have a script that loops over several search/replace regex in python, one of those operations is remove trailing spaces
  I've tried:</p>
  
  <pre class="lang-python prettyprint-override"><code>re.sub(r"""\s+$""", '', str)
  
  re.sub(r""" +$""", r"""""", str)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>re.sub(r""" +$""", r"""""", str, re.M)
  </code></pre>
  
  <p>I found several answers that simply recommended using <code>strip</code> my problem is that I want to integrate this in the regex replace mechanism.</p>