title: How to replace the tabs at the beginning of a new line using regex?
body: <p>I'm using java to try to replace the four spaces at the beginning of a new line to a tab. I would like to do this using regular expressions. My issue is that the regex is currently replacing all four-space-sequences with a single tab. I want it to insert a tab for each four-space-sequence. Right now I have: </p>
  
  <pre><code>    public String translate(String text) {
          text = text.replaceAll("(?m)^(    )+", "\t");
          return text;
  }
  </code></pre>