title: Replace multiple consecutive occurrences of a character with a single occurrence
body: <p>I am making a natural language language processing application in Java, I am using data from IMDB and Amazon.</p>
  
  <p>I came across a certain dataset which has words like <code>partyyyyy</code>. These words are not good for my classification algorithm. So, I want to remove them and add <code>party</code> instead of <code>partyyyyyyy</code>.</p>
  
  <p>How can I do that?</p>