Q: The function of re.search is __________
Solution: The re module of Python consists of a function re.search. It’s function is to match a pattern from anywhere in a string.
Q: Which of the following functions creates a Python object?
Solution: The function re.compile(srt) compiles a pattern of regular expression into an object of regular expression. Hence re.compile(str) is the only function from the above options which creates an object.
Q: Which of the following pattern matching modifiers permits whitespace and comments inside the regular expression?
Solution: The modifier re.X allows whitespace and comments inside the regular expressions.
Q: The function of re.match is ____________
Solution: The function of re.match matches a pattern at the start of the string.
Q: The special character B matches the empty string, but only when it is _____________
Solution: The special character B matches the empty string, but only when it is not at the beginning or end of a word.
Q: Which of the following special characters matches a pattern only at the end of the string?
Solution: B matches a pattern which is not at the beginning or end of a string. X refers to re.VERBOSE. A matches a pattern only at the start of a string. matches a pattern only at the end of a string.
You Have Score    | /6 |