Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Write down the extended regular expression for following questions E.g. Socia

ID: 3586404 • Letter: 2

Question

2. Write down the extended regular expression for following questions E.g. Social security number in the format of 999-99-9999.

Answer: [0-9]{3}-[0-9]{2}-[0-9]{4} (10 points, each 2 points) 1) Valid URL beginning with “http://”. (e.g. https://www.michigan.edu)

2) Valid variable name following the two rules below:

Must begin with a letter of the alphabet, an underscore, or ( _ ), or a dollar sign ($)

After the first initial letter, variable names may also contain letters and the digits 0 to 9.

3) Valid email address, assuming ‘ a-z’,’0-9’,’_‘,’.’ are valid characters for user id and domain name has to be end with either “.com” or “.net” (e.g. aabb_123.xy@g3.com, cdcd@12_3.net)

4) Phone number in any of the following format: 999-9999999,999-999-9999, (999)-9999999. (Note: all of these formats should be matched by a single regular expression) 5) Valid HTML link tag with the format: ... . (e.g. O’Reilly Media , Download Test )

Explanation / Answer

Write down the extended regular expression for following questions E.g. Social security number in the format of 999-99-9999.

Ans: [0-9]{3}-[0-9]{2}-[0-9]{4}

1) Valid URL beginning with “http://”. (e.g. https://www.michigan.edu)
Ans: http://.*4

3) Valid email address, assuming ‘ a-z’,’0-9’,’_‘,’.’ are valid characters for user id and domain name has to be end with either “.com” or “.net”
Ans:[a-z0-9-.]+@[a-z0-9-]+.(com|net)


4) Phone number in any of the following format: 999-9999999,999-999-9999, (999)-9999999. (Note: all of these formats should be matched by a single regular expression)
Ans: (?[0-9]{3})?-[0-9]{3}-?[0-9]{4}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote