Detect the Email Addresses

Sort by

recency

|

172 Discussions

|

  • + 0 comments

    Interesting challenge — I had to deal with something similar while cleaning up email data for a Shopify store I work with (opux.co.uk).

    We were syncing subscriber lists from Klaviyo, and a few invalid or malformed addresses were breaking the automation flow. Using a regex pattern similar to the one in this problem helped filter those out before import.

    Never realized how handy these small regex exercises can be in real-world marketing setups until then!

  • + 0 comments
    import re
    l=[]
    for _ in range(int(input())):
        n=input()
        m=re.findall(r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}",n)
        l.extend(m)
    print(";".join(sorted(set(l))))
            
    				
    
  • + 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.

  • + 0 comments

    Enter your code here. Read input from STDIN. Print output to STDOUT

    this works for me

    import re import sys

    html= sys.stdin.read()

    pattern= r'\w*.?\w+@\w+.?\w*.?\w*.?\w+'

    matches=re.findall(pattern,html)

    output=sorted(set(email for email in matches))

    print(';'.join(output))

  • + 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;