title: Java regexp groups replacements
body: <p>Is there a way to transform the String</p>
  
  <pre><code>"m1, m2, m3"
  </code></pre>
  
  <p>to the following</p>
  
  <pre><code>"m1/build, m2/build, m3/build"
  </code></pre>
  
  <p>only by using <code>String.replaceAll(regex, replacement)</code> method?</p>
  
  <p>So far this is my best attempt:</p>
  
  <pre><code>System.out.println("m1, m2, m3".replaceAll("([^,]*)", "$1/build"));
  &gt;&gt;&gt; m1/build/build, m2/build/build, m3/build/build
  </code></pre>
  
  <p>As you can see the output is incorrect. However, using the same regexp in Linux's <code>sed</code> command gives correct output:</p>
  
  <pre><code>echo 'm1, m2, m3' | sed -e 's%\([^,]*\)%\1/build%g'
  &gt;&gt;&gt; m1/build, m2/build, m3/build
  </code></pre>