title: Javascript regex not returning match
body: <p>I have a simple regex in which I'm trying to extract the leading value including the brackets. But for some reason it returns the entire string every time.</p>
  <p>Sample string <code>[1] My well-being</code> if it includes <code>[####]</code> i want to then be able to get the contents of the match results so i can get <code>[4]</code> as a result.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const arr = [
    'I am not valid',
    '[1] My well-being',
    '[1] I conversation about',
    '[3] I role within',
    '[3] I members in the company',
    '[3]I priorities',
    '[3]How other teams',
    '[4] I within a team',
    '[4] I am a peer',
    '[4] I am a label',
    '[4] I am a label'
  ]
  
  const regex = /^(\[\d+\])(.*)/img;
  for (let index = 0; index &lt; arr.length; index++) {
    const name = arr[index];
    const match = name.match(regex);
    console.log(match)
  }</code></pre>
  </div>
  </div>
  </p>