Question 17Asked in UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)

Which of the following strings would match the regular expression : p+[3 – 5]*[xyz]?

Which of the following strings would match the regular expression : p+[3 – 5]*[xyz]? I. p443y II. p6y III. 3xyz IV. p35z V. p353535x VI. ppp5
  1. AI, III and VI only
  2. BIV, V and VI only
  3. CII, IV and V only
  4. DI, IV and V only
Show answerHide answer

Correct answer: (D) I, IV and V only

Explanation

p+[3–5]*[xyz] = one or more p, then any number of 3, 4 or 5, then exactly one of x, y, z. (I) p443y → matched (II) p6y → not matched, since 6 cannot be used (III) 3xyz → not matched, string must start with p (IV) p35z → matched (V) p353535x → matched (VI) ppp5 → not matched, string must end with x, y or z

From UGC NET Computer Science PYQ, June 2017 (Paper II & III, Selected Questions)

This is question 17 of UGC NET Computer Science PYQ, June 2017 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.