title: Use regex to replace sequences in a string with modified characters
body: <p>I am trying to solve a <a href="http://codingbat.com/prob/p158175" rel="nofollow">codingbat</a> problem using regular expressions whether it works on the website or not.</p>
  
  <p>So far, I have the following code which does not add a <code>*</code> between the two consecutive equal characters. Instead, it just bulldozes over them and replaces them with a set string.</p>
  
  <pre><code>public String pairStar(String str) {
      Pattern pattern = Pattern.compile("([a-z])\\1", Pattern.CASE_INSENSITIVE);
      Matcher matcher = pattern.matcher(str);
      if(matcher.find())
      matcher.replaceAll(str);//this is where I don't know what to do
      return str;
  }
  </code></pre>
  
  <p>I want to know how I could keep using regex and replace the whole string. If needed, I think a recursive system could help.</p>