Hackerss.com

Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in
hackerss
hackerss

Posted on

Python Validate phone numbers


import re

def phone_number_validator(number):
    """
    This function validates phone numbers.
    """
    pattern = re.compile(r'^[6-9]\d{9}$')
    if pattern.match(number):
        return True
    return False

def email_validator(email):
    """
    This function validates email.
    """
    pattern = re.compile(r'^[a-zA-Z0-9_.][email protected][a-zA-Z0-9]+\.[a-zA-Z0-9.]+$')
    if pattern.match(email):
        return True
    return False

def main():
    """
    This is main function.
    """
    number = input()
    email = input()
    print(phone_number_validator(number))
    print(email_validator(email))

if __name__ == '__main__':
    main()
Enter fullscreen mode Exit fullscreen mode

Top comments (0)