1.

Which of the following statements regarding the output of the function re.match is incorrect?(a) ‘pq*’ will match ‘pq’(b) ‘pq?’ matches ‘p’(c) ‘p{4}, q’ does not match ‘pppq’(d) ‘pq+’ matches ‘p’The question was posed to me in an online quiz.Question is taken from Regular Expressions topic in section Regular Expressions and Files of Python

Answer»

Right answer is (d) ‘pq+’ matches ‘p’

EXPLANATION: All of the above statements are correct except that ‘pq+’ match ‘p’. ‘pq+’ will match ‘p’ FOLLOWED by any non-zero number of Q’s, but it will not match ‘p’.



Discussion

No Comment Found

Related InterviewSolutions