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

Part II: Regular Expression 1. Chose match(es) for each given basic/extended reg

ID: 3888052 • Letter: P

Question

Part II: Regular Expression 1. Chose match(es) for each given basic/extended regular expression (maybe multiple correct matches) and describe the pattern of matched string for 3), 4), 5),6), 11) e.g. (ab+a, (extended regex ) a) ababa b) aba c)abba d)aabba e)aa Answer: b,c; Pattern : The matched string should begin and end with 'a and ‘b' occurs at least once between leading and ending ‘a') ote: 1) to 5)are basic regexes 1) 'a[ab]*a' (a)ababa (b) aaba (c) aabab (d) aabbaa (e)aa 2) 'a(bc)?' (a) abc (b) a(bc)? (c) a(bc (d) a (e) abcbc 3) ind] (a) wind (b) window (c) end(d) good (e)will (a) a+b+c (b) +b (d) x+1 (e) x+a ote: 5) to 12) are extended regexes (a) a+b+c(b) +b (d) x+1 (e) x+a (a)azbc (b) az(c) azbcbc (d) acc (e)acz 7) a.[0-9]' (a)azz (b) a0z (c) a01 (d) a0a (e)aza (a)good! (b) Book. (c) hard? (d) cool?hot (e)nothing

Explanation / Answer

Please give the thumbs up, if it is helpful for you!!. Let me know if you have any doubts.

1) a,b,d,e

2) a,d

3) a,b,c,d,e

Describe: [ind]* will find any of the letter i,n,or d in the string.

4) no pattern will match from options

Describe: [a-z]+ will find letters one and unlimited times,and [a-z] find single letter.
+ Quantifier — Matches between one and unlimited times,

5) a

Describe: [a-z] find single character. + will find '+' operator.
(+[a-z])+ means one or more times + followed by letter ..like +a+b+d

6) a,c,d

Describe: a.[bc]+ Matches a then any single character followed by one or more b or c.
dot Matches any single character except .

7) c

Describe: there should be one digit at the end

8) a,c

Describe: any number of character follwed by either . or ? or !

9) b

10) no option will match because all options have white space present but in regular
expression there is no expression to handle white spaces.

11) a,b


Describe: -?[0-9]+ matches -(dash) zero or one time followed by one or more digits.
? Matches the previous element zero or one time.


12) a,b,d

Describe: -?[0-9]*.?[0-9]* matches -(dash) zero or one time followed by one or more digits followed by
.(dot) then followed by zero or more digits.
? Matches the previous element zero or one time.