title: Java Regex to count & delete spaces at beginning of a line?
body: <p>Searched other questions couldn't find any results.</p>
  <p>I've written a regex to delete the spaces from the beginning of the line, but I need to count them and have them at the beginning of the line?</p>
  <pre class="lang-java prettyprint-override"><code>scan.nextLine().replaceAll(&quot;\\s+&quot;, &quot;&quot;).trim();
  </code></pre>
  <p>Above is the regex (it's in a while loop).  I'm reading in the text in a while loop to check if there is more text and it works fine but I don't know how I can print an integer with the number of spaces removed.</p>