title: Regular expression capable of extracting email from strings
body: <p>So I have those examples:</p>
  <ul>
  <li><code>&quot;torvalds@linux.org&quot;</code></li>
  <li><code>&quot;Elon &lt;42069@tesla.com&gt;&quot;</code></li>
  <li><code>&quot;Suzzy@Typo.com &lt;suzzy@peppapig.com&gt;&quot;</code></li>
  </ul>
  <p>with one regular expression I would like to be able to extract from them respectively:</p>
  <ul>
  <li><code>&quot;torvalds@linux.org&quot;</code></li>
  <li><code>&quot;42069@tesla.com&quot;</code></li>
  <li><code>&quot;suzzy@peppapig.com&quot;</code></li>
  </ul>
  <p>My miserable attempts were able me so far to came up with something like:</p>
  <p><code>/^(?:([^&lt;&gt;]+)|(?:.*&lt;(.*?)&gt;))$/</code></p>
  <p>but with that I'm not able to make a single group capture an email address:</p>
  <pre><code>&gt; var emailRegex = /^(?:([^&lt;&gt;]+)|(?:.*&lt;(.*?)&gt;))$/;
  undefined
  &gt; linus.match(emailRegex)
  [
    'torvalds@linux-foundation.org',
    'torvalds@linux-foundation.org',
    undefined,
    index: 0,
    input: 'torvalds@linux-foundation.org',
    groups: undefined
  ]
  &gt; SuzzysEmail.match(emailRegex)
  [
    'Suzzy@PeppaTypoPig.com &lt;suzzy@peppapig.com&gt;',
    undefined,
    'suzzy@peppapig.com',
    index: 0,
    input: 'Suzzy@PeppaTypoPig.com &lt;suzzy@peppapig.com&gt;',
    groups: undefined
  ]
  &gt; elonsEmail.match(emailRegex)
  [
    'Elon Musk &lt;42069@tesla.com&gt;',
    undefined,
    '42069@tesla.com',
    index: 0,
    input: 'Elon Musk &lt;42069@tesla.com&gt;',
    groups: undefined
  ]
  </code></pre>
  <p>and I don't want to refere once to email with <code>.match(emailRegex)[1]</code> and <code>.match(emailRegex)[2]</code> in other cases. I'm sure there is a better way.</p>