From b0ec539933f01b272e5756552075c4153e25bbd2 Mon Sep 17 00:00:00 2001 From: susang Date: Sat, 2 Oct 2021 14:37:35 +0545 Subject: [PATCH] added email_validation --- .../Python_Programs/regex.py | 1 + .../Python_Programs/regex_email_validator.py | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 Program's_Contributed_By_Contributors/Python_Programs/regex_email_validator.py diff --git a/Program's_Contributed_By_Contributors/Python_Programs/regex.py b/Program's_Contributed_By_Contributors/Python_Programs/regex.py index e77c753367..04f02f2bd3 100644 --- a/Program's_Contributed_By_Contributors/Python_Programs/regex.py +++ b/Program's_Contributed_By_Contributors/Python_Programs/regex.py @@ -13,3 +13,4 @@ def str_match(self, pattern, string): return True else: return False + diff --git a/Program's_Contributed_By_Contributors/Python_Programs/regex_email_validator.py b/Program's_Contributed_By_Contributors/Python_Programs/regex_email_validator.py new file mode 100644 index 0000000000..2fb58b2807 --- /dev/null +++ b/Program's_Contributed_By_Contributors/Python_Programs/regex_email_validator.py @@ -0,0 +1,11 @@ +import re # import regex module + +# validate email +def email_validation(self, email): + if re.fullmatch(r"/[A-Z0-9._%+-]+@[A-Z0-9-]+.+.[A-Z]{2,4}/igm", email): + return True + else: + return False + + +email_validation("home@gmail.com") # returns True/False