title: How to format string to a particular pattern
body: <p>Let's say I have an input string and I need to format it like this:</p>
  
  <pre><code>### ### ############........etc
  </code></pre>
  
  <p>so it has to have first three chars, then a space, then another three chars, space and then the rest. Is there a third-party library or JDK Class that is able to do that?</p>
  
  <p>I was trying to use regular expressions</p>
  
  <pre><code>System.out.println(inputString.replaceAll(".{3}", "$0 "));
  </code></pre>
  
  <p>but it's not working because the result is</p>
  
  <pre><code>### ### ### ### ### etc.
  </code></pre>