Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- regex = re.compile(("([a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`"
- "{|}~-]+)*(@|\sat\s)(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(\.|"
- "\sdot\s))+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)"))
- bkav = open("bkav.txt", "r", encoding='utf-8').read()
- def get_emails(s):
- """Returns an iterator of matched emails found in string s."""
- # Removing lines that start with '//' because the regular expression
- # mistakenly matches patterns like 'http://foo@bar.com' as '//foo@bar.com'.
- return (email[0] for email in re.findall(regex, s) if not email[0].startswith('//'))
- h = open("bkav3.txt","w", encoding='utf-8')
- for a in get_emails(bkav):
- print(a)
- h.write(a)
- h.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement