title: remove multiple consecutive occurrences of .* in a string with a single .* python
body: <p>Below is my code to check for the multiple consecutive occurrences of  <code>".*"</code>
  in string. If there are multiple consecutive occurrences of <code>".*"</code> then replace it with single <code>".*"</code>. Forg:</p>
  
  <pre><code>import re
  
  dot_star_check = re.compile('(\.\*){2,}')
  
  k = ".*.*.*.*.*foo.*"
  
  k = k.replace(?,".*") if dot_star_check.search(k) else k
  
  print k
  </code></pre>
  
  <p>What i should write instead of ? to replace multiple consecutive occurrences of <code>.*</code> with single <code>.*</code></p>
  
  <p>So, expected output is <code>.*foo.*</code></p>
  
  <p>other egs:</p>
  
  <p>1.) <code>foo.*.*.*.*bar.* -&gt;foo.*bar.*</code></p>
  
  <p>2.) <code>.*foobar.*.*.*.*.* -&gt;.*foobar.*</code></p>