Advertisement
kstoyanov

06. Extract Emails js fundamentals

Jul 29th, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(args) {
  2.   const exEmails = [];
  3.  
  4.   args.forEach((str) => {
  5.     const emailReg = str.match(/(^|(?<=\s))(([a-zA-Z0-9]+)([\.\-_]?)([A-Za-z0-9]+)(@)([a-zA-Z]+([\.\-_][A-Za-z]+)+))(\b|(?=\s))/g);
  6.  
  7.     if (emailReg !== null) {
  8.       exEmails.push(emailReg);
  9.     }
  10.   });
  11.  
  12.   if (exEmails !== 0) {
  13.     exEmails.forEach((email) => {
  14.       console.log(email.join('\n'));
  15.     });
  16.   }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement