title: Javascript regex to extract year from string
body: <p>I'm trying to extract the year from a timestamp using regex, but I'm not very good at it, so my code isn't returning what expected.</p>
  
  <p>that's the string: '<strong>Sun Jan 01 2012 00:00:00 GMT+0000 (GMT)</strong>'</p>
  
  <p>I need to extract '2012' here's my code:</p>
  
  <pre><code>var scrollDate = tl.getBand(0).getCenterVisibleDate(); // my timestamp
  
  // regex function
  function extractNumbers(str) {
       var m = /(^|\s)(\d{4})(\s|$)/.exec(str);
       return m;
  }
  
  // click event
  $('.n-left').click(function(){
       alert(extractNumbers(scrollDate));
  });
  </code></pre>
  
  <p>The alert box returns this: <strong>2012 , ,2012,</strong> </p>
  
  <p>What am I doing wrong?
  Thanks in advance</p>