
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python Program to extract email-id from URL text file
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 contact@tutorialspoint.com for further information."+\ " You can also give feedback at feedback@tutorialspoint.com" Output ['contact@tutorialspoint.com ','feedback@tutorialspoint.com']
Example code
import re my_text = "Please contact us at contact@tutorialspoint.com for further information."+\ " You can also give feedback at feedback@tutorialspoint.com" my_emails = re.findall(r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", my_text) print (my_emails)
Output
['contact@tutorialspoint.com', 'feedback@tutorialspoint.com’]
- Related Articles
- How to extract email id from text using Python regular expression?
- How to use Python Regular expression to extract URL from an HTML link?
- How to extract numbers from text using Python regular expression?
- How to extract date from text using Python regular expression?
- How to extract text from a web page using Selenium and save it as a text file?
- MySQL query to fecth the domain name from email-id?
- Extract hostname from URL string in JavaScript?
- How to extract floating number from text using Python regular expression?
- Java program to delete certain text from a file
- Python program to extract Keywords from a list
- How to create a Python dictionary from text file?
- How to validate an email id using regular expression in Python?
- How to extract file extension using Python?
- How to extract text from a Javascript alert in Selenium with python?
- Golang program to read entire text from the existing file

Advertisements