Guest User

Untitled

a guest
Sep 26th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. const extractEmails = (text) => {
  2. const match = text.match(/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/gi);
  3. return match !== null ? match : [];
  4. }
  5.  
  6.  
  7. // text => 'first <first@mail.com>, second <second@mail.com> notamail.com bb@mail.com'
  8. // extractEmails(text) => ['first@mail.com', 'second@mail.com', 'bb@mail.com']
Add Comment
Please, Sign In to add comment