From 008b3008fe19d30dcad577ff1732f38cd1d28821 Mon Sep 17 00:00:00 2001 From: Richie de la Rosa Date: Thu, 25 Sep 2025 22:13:47 -0400 Subject: [PATCH] Added regex for more robust validation. --- Address Validator/AddressValidator.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Address Validator/AddressValidator.py b/Address Validator/AddressValidator.py index 0dc49be1..cbf2f7b2 100644 --- a/Address Validator/AddressValidator.py +++ b/Address Validator/AddressValidator.py @@ -1,16 +1,11 @@ -def addressVal(address): - dot = address.find(".") - at = address.find("@") - if (dot == -1): - print("Invalid") - elif (at == -1): - print("Invalid") - else: - print("Valid") +import re print("This program will decide if your input is a valid email address") while(True): - print("A valid email address needs an '@' symbol and a '.'") - x = input("Input your email address:") + print("A valid email address must be in the format example@example.com.") + x = input("Input your email address: ") - addressVal(x) + result = re.fullmatch(r'^\S+@\S+\.\S+', x) + + if result: + break \ No newline at end of file