title: Counting beginning whitespaces
body: <p>I want to count (within a single regular expression) all spaces at the beginning of a string.</p>
  
  <p>My ideas:</p>
  
  <pre><code>$identSize = preg_match_all("/^( )[^ ]/", $line, $matches);
  </code></pre>
  
  <p>For example:</p>
  
  <pre><code>$example1 = " Foo"; // should return 1
  $example2 = "  Bar"; // should return 2
  $example3 = "   Foo bar"; // should return 3, not 4!
  </code></pre>
  
  <p>Any tips, how I can resolve it?</p>