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

Write a Regular Expression, requirements: 1. They contain letters, digits, and p

ID: 3923431 • Letter: W

Question

Write a Regular Expression, requirements:

1. They contain letters, digits, and punctuation symbols

2. They must contain at least a letter and a number, and at least one but at most two punctuation symbols

3. They cannot start with a punctuation symbol

Using exclusively the regular expresssion operators epsilon(empty), * (zero or more copies), and + (concatenation), write a regular expression denoting the set of all passwords that satisfy these requirements. For brevity, use: L, D, and P to denote Letter, Digit, and Punctuation, respectively.

My answer: ( LD ) ( P + PP ) ( L + D )* + ( DL ) ( P + PP ) ( L + D )* ... but I don't think it is correct.

Explanation / Answer

So the required expression can be written as follows:

^[ LDP ]* + [ LD ] [ LDP ]*

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