Here we are using regular expression package for extracting email-id from the URL-text file. Given the URL- text file. Using regular expression package we define the pattern of email-id then use findall() function, using this method to check the text which will match with this pattern.
Input text= Please contact us at [email protected] for further information."+\ " You can also give feedback at [email protected]" Output ['[email protected] ','[email protected]']
Example code
import re my_text = "Please contact us at [email protected] for further information."+\ " You can also give feedback at [email protected]" my_emails = re.findall(r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", my_text) print (my_emails)
Output
['[email protected]', '[email protected]’]