Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1: Regular Expressions (10%) Write a regular expression pattern matching a valid Email address. For the purposes of this exercise, a valid Email address
Question 1: Regular Expressions (10%) Write a regular expression pattern matching a valid Email address. For the purposes of this exercise, a valid Email address is any string of the form local@domain where . local is any combination of alphanumeric (i.e., both letters and numbers) charcters in either lower or upper case, dots ( . ) and the following characters !#5%6' *+-/s? ^_ { | } ~ , and domain is a sequence of labels separated by a single . (dot) character where each label is a combination of alphanumeric (i.e., both letters and numbers) characters in either lower or upper case, and the rightmost label representing the top-level domain is not all numbers For example, all of the following strings are valid EMails: joe@example.com, joe.doe@bigdata.cs.rhul.ac.uk, joe.doe123$@stratospheric, j0e. .D_OE@123dotcom.net, and the strings joe@doe.xxx@example.com, joe@.example.com, joe.doe@example.123, and joe.doe@example.123..com are all invalid. In [21]: import re # Put your pattern inside ' ' email-regex = 'l' Your solution is correct if the value returned by re.compile (email_regex).fullmatch(s) is not None for every string s, which is a valid Email address according to the definition above, and None, otherwise
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started