question archive Pass Task 2

Pass Task 2

Subject:Computer SciencePrice:9.82 Bought3

Pass Task 2.3P: Email validation using regular expression Task description: Use regular expression to implement a function which accepts a passed string and check if it is a valid email address. A program accepts user's input and calls the email validation function. If the email is valid, print out the email, username and host. (Rule: word characters (a-zA-Z0-9_or "\w"), dot, and hyphen are considered as valid characters in an email address, besides of one & only one @'.) (Sample output as shown in the following figure is for demonstration purposes only.) In [24]: runfile( 'C: /tmp/units/2020/SIT384-2020-1/portfolio/week2/ Task2. 3P.py', wdir='C:/tmp/units/2020/SIT384-2020-1/portfolio/week2' ) Please input your email address : test@ Not a valid email. Please input your email address : shang . gao@test2. server. com email: shang . gao@test2. server. com , username: shang. gao , host: test2. server . com Submission: Submit the following files to On Track: 1. Your program source code (e.g. task2-3.py) 2. A screen shot of your program running Check the following things before submitting: 1. Add proper comments to your code

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Regular Expressions, often known as "regex" or "regexp," are being used to matching text strings such as specific letters, words, and character pattern. It implies that we can use regular expressions to identify or retrieve any text sequence from texts.

Step-by-step explanation

email_address = input("Input you email address ")
while "@" not in email_address:
    email_address = input("Your email address must have '@' in it\nInput write your email address again: ")
    if len(email_address) <= 6 :
        email_address = input("Your email address is too short\nInput write your email address again: ")
    if "." not in email_address:
        email_address = input("Your email address must have '.' in it\nInput write your email address again: ")
while "." not in email_address:
    email_address = input("Your email address must have '.' in it\nInput write your email address again: ")
    if len(email_address) <= 6 :
        email_address = input("Your email address is too short\nInput write your email address again: ")
    if "@" not in email_address:
        email_address = input("Your email address must have '@' in it\nInput write your email address again: ")

email address = input(&quot;Input you email address Input you email address jj while &quot;@&quot; not in email_address: Your email address must have '@' in it email_address = input(&quot;Your email address must have '@' in Input write your email address again: it\nInput write your email address again: &quot;) if len(email_address ) &lt;= 6 : email_address = input(&quot;Your email address is too short\Input write your email address again: &quot;) if &quot;.&quot; not in email_address: email_address = input(&quot;Your email address must have ' . ' in it\nInput write your email address again: &quot;) while &quot;.&quot; not in email address: email_address = input(&quot;Your email address must have ' . ' in it\nInput write your email address again: &quot;) if len(email_address) &lt;= 6 : email_address = input(&quot;Your email address is too short\nInput write your email address again: &quot;) if &quot;@&quot; not in email_address: email_address = input(&quot;Your email address must have '@' in it\nInput write your email address again: &quot;)