Detect the Email Addresses

  • + 1 comment

    Python 3

    import re
    import sys
    n = int(input())
    string = sys.stdin.read()
    
    pattern = r'((\w+(\.\w+)*)@(\w+(\.\w+)*))'
    matches = re.finditer(pattern, string)
    email = set()
    for match in matches:
        email.add(match.group(0))
    print(";".join(sorted(list(email)))