title: How to remove a number inside brackets at the end of string with regex
body: <p>Looking to have a recursive function that takes a string and removes the ending '[x]'. For example 'abc [1] [3]' needs to be 'abc [1]'.  The string could also be 'abc [1] [5] [2]' and would need to be 'abc [1] [5]'. </p>
  
  <p>I'm trying <code>str.replace(/[\\\[\d\\\]]$/, '')</code> but it only replaces the very last closing bracket and ignores everything else.</p>
  
  <p>Any ideas?</p>