-5

my text file is saved on my desktop which contains my resume i want to extract my E-mail from the text file can some one help me My txt file has

Name                        :      K. Spandana

Gender                      :      Female

Nationality                 :      Indian

Marital Status              :      Unmarried
Mother tongue               :      Telugu
Languages Known             :      English, Hindi and Telugu
Address of Correspondence   :      H.NO:4-56/1, Hanuman nagar ,Post: Theegalaguttapalli,

E-mail ID                   :      Spandanareddy.kallepu@gmail.com

i have tried https://gist.github.com/dideler/5219706 code with file path

SAKETH
  • 9
  • 5

1 Answers1

0

Something like the following will work:

with open('resume.txt', 'r') as f_input:
    print re.findall(r'\b([a-z0-9-_.]+?@[a-z0-9-_.]+)\b', f_input.read(), re.I)

It will display:

['Spandanareddy.kallepu@gmail.com']

But the exact logic can be far more complicated. It all depends on how accurate it needs to be.

This will display all email addresses in the text file, just in case there is more than one.

Community
  • 1
  • 1
Martin Evans
  • 45,791
  • 17
  • 81
  • 97