Skip to content

Instantly share code, notes, and snippets.

@pySamurai
Created August 9, 2018 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pySamurai/4f4eb8c3474e8ff8e05ac28347113781 to your computer and use it in GitHub Desktop.
Save pySamurai/4f4eb8c3474e8ff8e05ac28347113781 to your computer and use it in GitHub Desktop.
import re
file_name = "path to file base.txt"
result_file_name = "path to file result.txt"
my_file = open(file_name, mode="r", encoding="UTF-8", )
results_file_read = open(result_file_name, mode="w", encoding="UTF-8")
my_text = my_file.read()
look_for = r"[\w.-]+@[A-Za-z-]+\.[\w.]+"
results = re.findall(look_for, my_text)
for item in results:
print(item)
results_file_read.write(item + "\n")
print("Total: " + str(len(results)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment