23 lines
658 B
Python
23 lines
658 B
Python
import regex as re
|
|
|
|
|
|
def get_email_addresses(usr_input: str) -> list:
|
|
return re.findall(r"^[A-Za-z0-9!#$%&'*+=?^_`{|}~.\-\/]{1,64}@[a-zA-Z0-9.\-]+$", usr_input)
|
|
|
|
|
|
def return_email_addresses_in_file(file_name: str) -> list:
|
|
f = open(file_name, "r")
|
|
email_addresses = []
|
|
for line in f:
|
|
email_addresses_from_line = get_email_addresses(line)
|
|
if email_addresses_from_line:
|
|
email_addresses.append(email_addresses_from_line)
|
|
f.close()
|
|
return email_addresses
|
|
|
|
|
|
if __name__ == '__main__':
|
|
usr_input = input("Podaj nazwe pliku: ")
|
|
for email in return_email_addresses_in_file(usr_input):
|
|
print(email)
|