Avatar of ResourcefulDB
ResourcefulDB asked on

email validation in python

hey, i have a little function in python to validate email. however aa@aa......com get pass. and aa@aa,com get pass too. how do we fix it.

thanks,
RDB.
def validateEmail(email_str):
        if (len(email_str)) > 6:
                if re.match("^[a-zA-Z0-9._%-]+@[a-zA-Z-9._%-]+.[a-zA-Z]{2,6}$",email_str) != None:
                        return 1
        return 0

Open in new window

PythonLinux

Avatar of undefined
Last Comment
arnold

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
wesly_chen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
arnold

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
pepr

ASKER
ResourcefulDB

arnold

The example is C code that evaluates a character at a time and changes the context when a character of interest i.e. @ which is the separator of user and domain/hostname.

You could repeat the same process in python, but the regular expression achieves the same result.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck