Skip to content

Commit

Permalink
Project code
Browse files Browse the repository at this point in the history
  • Loading branch information
kuldeep27396 authored Apr 30, 2020
1 parent d74f3a3 commit a3a1c6e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions EP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#E-mail and phone number extractor

import pyperclip

import re

#Text containing email's and phone number to be pasted from clipboard
text = str(pyperclip.paste())

#Regular expression for phone numbers

phone_regex = re.compile(r'''(
(\d{3}|\(\d{3}\))? # Non greedy approach for area code
(\s|-|\.)? # hypen or a dot (Phone number format)
(\d{3}) # first 3 digit
(\s|-|\.)? # seperator
(\d{4}) # Last 4 digit
)''', re.VERBOSE)

email_regex = re.compile(r'''(
[a-zA-Z0-9._%+-]+ # Username
@ # symbol
[a-zA-Z0-9.-]+ # domain name
(\.[a-z{2,4}]) # dot-something
)''', re.VERBOSE)

match =[] # list for storing all the matched found

for groups in phone_regex.findall(text):
phone_number = '-'.join([groups[1],groups[3],groups[5]])
match.append(phone_number)

for groups in email_regex.findall(text):
match.append(groups[0])

# Copy results to clipboard

if len(match)>0:
pyperclip.copy('\n'.join(match))
print ('Copied to clipboard')
print ('\n'.join(match))
else:
print ('Nothing found')




0 comments on commit a3a1c6e

Please sign in to comment.