Detect the Email Addresses

  • + 0 comments

    JavaScript

    I made it so complex, even I got confused.

    function processData(input) {
        let criteria = /([a-z\d._]+)@([a-z\d._]+\.[a-z]+)/gi;
        let arr = input.match(criteria);
        let emails = [...new Set(arr)];
        console.log(emails.sort().join(";"));
    }
    

    Corrected regex: let criteria = /[\w._]+@[\w._]+[\w]/g;