title: Get all email addresses in a string with JavaScript
body: <p>So, I have this JavaScript function:</p>
  
  <pre><code>ME.Utils = {
      RxEmail: new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i),
  
      ValidateEmail: function(email) {
          return ME.Utils.RxEmail.test(email);
      },
  
      GetEmailAddresses: function(text) {
          return text.match(ME.Utils.RxEmail);
      },
  
      HasEmail: function(text) {
          return ME.Utils.GetEmailAddresses != null;
      }
  };
  </code></pre>
  
  <p><code>ValidateEmail</code> works very well. However, <code>HasEmail</code> and <code>GetEmailAddresses</code> is not working properly.</p>
  
  <p><code>GetEmailAdresses</code> always returns <code>null</code>, except for when the string only contains an email address. In this case, <code>GetEmailAdresses</code> returns an array not only containing the email address, but the email address (test@test.com), just the id (test) plus some unidentified etc. etc...</p>
  
  <p>Can you help me figure out what's wrong in my expression?</p>