title: How to strip whitespace from before but not after punctuation in python
body: <p>relative python newbie here.  I have a text string output from a program I can't modify. For discussion lets say:</p>
  
  <pre><code>text = "This text . Is to test . How it works ! Will it! Or won't it ? Hmm ?"
  </code></pre>
  
  <p>I want to remove the space before the punctuation, but not remove the second space.  I've been trying to do it with regex, and I know that I can match the instances I want using 
  match='\s[\?.!\"]\s' as my search term.    </p>
  
  <pre><code>x=re.search('\s[\?\.\!\"]\s',text)
  </code></pre>
  
  <p>Is there a way with a re.sub to replace the search term with the leading whitespace removed? Any ideas on how to proceed? </p>