title: Regex to find common typos in Python
body: <p>I want to make a regular expression to find common typos such as multiple spaces between words, accidentally accidentally repeated words, or multiple exclamation marks at the end of sentences.</p>
  
  <pre><code>def f(m):
      return m.group(1)
  a=re.compile(r'(?P&lt;name&gt;(\D+|\s))(?P=name)+')
  b=a.sub(f,'text text text text and hi hi hipo !!!       1234 ')
  print(b)
  </code></pre>
  
  <p>I want to display on the screen: <code>text text and hi hipo ! 1234</code>
  but I still can't fix the problem of multiple spaces between words.</p>
  
  <p>I hope you guys can help me fix this problem.</p>