From 9a2fcf68c113af7d9c9a5e4e2bb687516fc6e8e2 Mon Sep 17 00:00:00 2001 From: seendsouza Date: Fri, 5 Oct 2018 20:21:39 -0400 Subject: [PATCH] added a python phone number validator --- telephone-validator/validator.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 telephone-validator/validator.py diff --git a/telephone-validator/validator.py b/telephone-validator/validator.py new file mode 100644 index 00000000..20365358 --- /dev/null +++ b/telephone-validator/validator.py @@ -0,0 +1,9 @@ +import re + +def tel_num_validator(telephone_number): + # Checks to see if input is a valid telephone number + return re.search("^\(?([0-9]{3})\)?[-.●]?([0-9]{3})[-.●]?([0-9]{4})$",telephone_number) + +if __name__ == "__main__": + telephone_number = input("Telephone Number: ") + print(tel_num_validator(telephone_number))