Regex Basics

Mon 30 June 2025
import re
text = "Contact us at sara123@gmail.com or call +91-9876543210"
email = re.findall(r"[a-zA-Z0-9._]+@[a-z]+\.[a-z]+", text)
print("Email:", email)
Email: ['sara123@gmail.com']
phone = re.findall(r"\+91-\d{10}", text)
print("Phone:", phone)
Phone: ['+91-9876543210']
Regex is used for pattern matching.
Useful in scraping, validation.

Score: 5

Category: basics