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

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

ID: 3745294 • Letter: P

Question

Part Il: 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) 6).11). eg. abta (extended regex Answer: bc ; Pattern : The matched string should begin and end with and b'occurs at least once between leading and ending 1) a(ab)a 2) a?lbc 3) Ind (a)ababa (b) aaba (c) aabab (d) aabbaa (eaa (a) abc (b)abc)bd) a?(e) abcbc (a) wind (b) window (c) end (d) good (e)will (b))6(d) a+6 e-1 5) a(alb)'a (a)ababa (b)aaba (c) aabab (d) aabbaa (eaa (a) x+9 (b)xy (c)1 1(d)y (e)xy 7) 'a (bc)' (b) az(c) azbcbc (d) acc (eaca 8) a [0.9] (a)al1 (b)a*2 ()b (d) abc (eaa (a)bash! (b)c (c) Java? (d) python (e)cs 10) "la-z)+M?!s"[A-Z), (hint: Vs matches any whitespace characters) (a)o. year(b)xy ()S (d)Hello HELLO (e)indexta 11) vey s)?(coolls) (goodlbad) weather (b) very cool weather (a)very weather (c) good weather (d) very cool good weather (e)col bad weather 12) 7(1O-9)101-9110-9)) (b)-123 ()0(d)-22 12 13) 0-9710-9] (b)-123 (c)0(d)-22 e1.2

Explanation / Answer

1. a[ab]*a

b. aaba is True
e. aa is True


2. a(bc)?
here the ? means bc or but nothing else

a. abc is True
d. a is True

3. .[ind]*
here [ind] represents i or n or d
* represents repetation of the above i or n or d
. represents any character before this

a. wind is True
c. end is True

4. [a-z]+[a-z]
e. x+a is True


5. "[a-z](+[a-z0-9])+"

It must contain any letter from a-z with a + followed by either a-z or 0-9.

a. a+b+c is true
d. x+1 is true
e. x+a is true

6. "az?(bc)*"

'a' followed by atleast 1 or more z followed by zero or more (bc)

a. azbc is true
b. az is true
c. azbcbc is true

7. "a.*[0-9]"

'a' followed by a digit

c. a01 is true

8."[a-z]+[\].\?!+]"

starts with a-z and followed by zero or more occurence of ! ?

a. bash! is true

b.c is true

c.java? is true

d.python! is true

9. [a-z]+[\.\?!]\s*[A-Z]
  
It must contain a ! followed by any space and then A-Z

b. done! H is true
  

10. (very)?(cool)+(good|bad)weather

Word very may occur 0 or more times followed by cool, followed by either good/bad
and end with weather.
  
b. very good weather is true
c. very cool bad weather is true
d. cool good weather is true
  
11. -?([0-9]|([1-9][0-9]))

a. o is true
c. -32 is true
e. -0 is true

12. -?[0-9]*\.?[0-9]*

a,b,c,d,e all are true.