title: replacing consecutive identical character using replace and replaceAll in Java
body: <p>I'd like to replace all occurrences of 2 consecutive commas (",,") by a marker in between, but I've found that I can't replace the second occurrence. The code is as follows:</p>
  
  <pre><code>String addresses = "a,,,b";
  String b = addresses.replace(",,", ",EMPTYADDR,");
  System.out.println(b);
  </code></pre>
  
  <p>I expect the result to be:</p>
  
  <pre><code>a,EMPTYADDR,EMPTYADDR,b
  </code></pre>
  
  <p>But instead, I get:</p>
  
  <pre><code>a,EMPTYADDR,,b
  </code></pre>
  
  <p>How should I change the code to get the desired result?</p>