title: Match and replace all tabs at the beginning of the line with four spaces
body: <p>I've read some other questions and answers on the site, but all of them were a little different from what I'm seeking: replace all tabs at the beginning of a string with four spaces.</p>
  
  <p>What I've tried so far:</p>
  
  <pre><code>let m = '\t\tsomething\t'
  </code></pre>
  
  <p>Finding tabs isn't hard with <code>/\t/g</code>, but this would get tabs that are not at the beginning of a line. So using <code>m.match(/(\t\W)/)</code> does the trick for the sample above, resulting in 2 matches.</p>
  
  <p>But when using <code>m.replace(/(\t\W)/, '    ')</code>, the expected result would be: </p>
  
  <pre><code>        something // 8 spaces (4 for each \t)
  </code></pre>
  
  <p>but I get this instead:</p>
  
  <pre><code>    something // 4 spaces for two tabs.
  </code></pre>
  
  <p>Why is this replacing both tabs just one time? And how can I replace every occurrence of <code>\t</code> with the desired string?</p>