title: JavaScript regex not returning match group
body: <p>I'm trying to get the content in between square brackets within a string but my Regex isn't working. </p>
  
  <p>RegExp: <code>/\[([^\n\]]+)\]/g</code></p>
  
  <p>It returns the correct match groups on regex101 but when I try something like <code>'[a][b]'.match(/\[([^\n\]]+)\]/g)</code>, I get <code>['[a]', '[b]']</code> instead of <code>['a', 'b']</code>.</p>
  
  <p>I can get the correct results if I iterate through and do RegExp.exec, but from looking at examples online it seems like I should be able to get the match groups using String.match</p>