Email Validation with Regex

Using regular expressions to validate email addresses

Python
import re

def validate_email(email):
    pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
    return re.match(pattern, email) is not None

emails = ['user@example.com', 'invalid.email@com', 'name@subdomain.example.co.uk']
for email in emails:
    print(f"{email}: {'Valid' if validate_email(email) else 'Invalid'}")