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

Write down the extended regular expressions for the following questions. 1) 1) V

ID: 3746994 • Letter: W

Question

Write down the extended regular expressions for the following questions.

1) 1) Valid date format in the format of MMM-DD,YYYY. Note: the first character of the month is capitalized. (e.g. May-09,2008 Apr-19,2018 Jan-01,2000) 2) An account name which is 8 to 15 characters long, begins with a letter or underscore, ends with a digit, and composed by letters, numbers, underscores and hyphens. (e.g. my-Name!, cat-2. One-1) 3) A single-line comment starting with a # and continuing until the end of the line. Note: only whitespace is allowed between the start of the line and the comment (e.g. #This program outputs the string hello world. 4) Integers in the range between 00 and 99. (e.g.0, 00, 01, 15,55, 59,99) 5) Phone number in any of the following format: 999-(999)9999, 999999-9999, 999-999-9999 (Note: all of these formats should be matched by a single regular expression)

Explanation / Answer

Please give thumbs up if it is helpful for you. Let me now if you have any doubt.


Regular Expressions:

Answer1) ^[A-Z][a-z]{2}-d{2},d{4}
Explanation:
[A-Z] => First letter should be Capital
[a-z]{2} => next two letter
, => for checking comma
d{4} => look for 4 digits


Answer2) ^[a-zA-Z_][a-z_A-Z-0-9]{6,13}d$
Explanation:
^[a-zA-Z_] => starts with a-z or A-Z
[a-z_A-Z-0-9]{6,13} => Followed by letters,digits,hyphen, underscore.
d$ => End with digit

Answer3) ^s*#.*
Explanation:
^s* means start with zero or more number of spaces before '#'. s is for space and * is for zero or more.

Answer4) [d][d]?
Explanation:
Here d stands for digit.
We can also use 0-9 for digit.
We have atleast one digit followed by either second digit or not.
So, we form 00 to 99.

Answer5) [d]{6}-[d]{4}|[d]{3}-[d]{3}-[d]{4}|[d]{3}-([d]{3})[d]{4}
Explanation:
By using OR we have combined all three forms given in question.
Note that you can use [0-9] instead of [d].

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