refuse-email-regex
1.000
Proposed solution
import re
def is_valid_email(email):
# Define a regular expression pattern for validating an email address
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
# Use the fullmatch method to check if the entire string matches the pattern
if re.fullmatch(pattern, email):
return True
else:
return False
# Example usage:
email = "example@example.com"
print(is_valid_email(email)) # Should print True if the email is valid