title: Replacing multiple occurences of special characters by a single special character
body: <p>I want to remove multiple occurrences of special characters like <code>" "</code>, <code>"-"</code>, <code>"!"</code>, <code>"_"</code> from my java string by a single underscore <code>"_"</code>. 
  I tried</p>
  
  <pre><code>replaceAll("([\\s\\-\\!])\\1+","_")
  </code></pre>
  
  <p>and it seems to replace consecutive same type of special character by a underscore but doesn't work otherwise.
  for eg:</p>
  
  <pre><code>Hello!!!  World
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>Hello__World
  </code></pre>
  
  <p>(2 underscores.)But It should be <code>Hello_World</code>.</p>
  
  <p>Also for cases like <code>Hello - World</code> it fails.
  I also tried working with regex and made a regular expression like </p>
  
  <pre><code>replaceAll("([^a-zA-Z0-9])\\1+","_")
  </code></pre>
  
  <p>but it still doesn't help. How can I achieve it?</p>