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

Note: The below regular expressions should utilize metacharacters, character cla

ID: 3854833 • Letter: N

Question

Note: The below regular expressions should utilize metacharacters, character classes, grouping, alternation, and quantifiers where applicable. Also, when creating your regular expressions, please use the notation from the lectures: /regular expression/

1. Write a regular expression that matches your name

2. Write a regular expression that matches the words Then and Than (use a character class)

3. Write a regular expression that matches the sequence yes or the sequence no

4. Write a regular expression that matches at least one d followed by any number of f's.

5. Write a regular expression that matches the structure of a social security number

6. Write a regular expression that matches all names that begin with a Mc (case sensitive)

7. Write a regular expression that will match all C++ files (files/names that end in a .c or .cc., don’t worry about cpp)

8. Write a regular expression that matches words that contain a sequence of vowels (aeiou) (e.g. jjjakkkollllu, akkkku, jallekkillllu)

9. Write a regular expression that matches words that begin and end with the letter b (e.g bob, bulb, etc)

10. For the below regular expression, give two examples that match the expression and two examples that do not match. Your examples that match and do not match the expression must include the characters x and y. The entire character set is x and y.

/x+y+/

11. For the below regular expression, give two examples that match the expression and two examples that do not match.

/[a-f]z?/

Explanation / Answer

1. Regular Expression that matches your name = ^[a-zA-Zs]+$

2. A regular expression that matches the words Then and Than (use a character class) = Use [he] = T[he]n =T[ha]n

3.A regular expression that matches the sequence yes or the sequence no = (?(id/name)yes-pattern|no-pattern)

4. a regular expression that matches at least one d followed by any number of f's. = /d+/f

5. a regular expression that matches the structure of a social security number =

(^d{3}-?d{2}-?d{4}$|^XXX-XXXXXX$)

6. a regular expression that matches all names that begin with a Mc (case sensitive) = ^Mc.*$

7. a regular expression that will match all C++ files = L"Project[0-9]{2}@txt

8. a regular expression that matches words that contain a sequence of vowels (aeiou) (e.g. jjjakkkollllu, akkkku, jallekkillllu) = ^a[^aeiou]*e[^aeiou]*$

9. a regular expression that matches words that begin and end with the letter b =  WORD 

10. /x+y+/ = bang,baang

11. /[a-f]z?/ = gangg

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