Detect the Email Addresses

  • + 0 comments

    JS

    let pat = new RegExp(/\b([\w.]+)@([\w.]+)\.(\w+)\b/, "gm");
    let occs = new Set(input.match(pat).sort());
    console.log([...occs].join(";"));
    

    \b <--- start and end of a "word" (or email) ---> \b

    \w = [a-zA-Z_]

    [\w.] : We don't need to scape dots inside those brackets.