Correct Answer is : Matches a pattern from any part of a string
12. Which of the following functions creates a Python object?
Correct Answer is : re.compile(str)
13. Which of the following pattern matching modifiers permits whitespace and comments inside the regular expression:
Correct Answer is : re.X
14. What is the output of the code shown below?
s = 'welcome home'
m = re.match(r'(.*)(.*?)', s)
print(m.group())
Correct Answer is : welcome home
15. The function of re.match is:
Correct Answer is : Matches a pattern at the start of the string
16. The special character \B matches the empty string, but only when it is:
Correct Answer is : not at the beginning or end of a word
17. The output of the code shown below is:
import re
s = "A new day"
m = re.match(r'(.*)(.*?)', s)
print(m.group(2))
print(m.group(0))
Correct Answer is : No output
18. Which of the following special characters matches a pattern only at the end of the string?
Correct Answer is : \Z
19. The output of the two codes shown below is the same. State whether true or false.
p = re.compile('hello')
r = p.match('hello everyone')
print(r.group(0))
r = re.match('hello', 'hello everyone')
print(r.group(0))
Correct Answer is : TRUE
20. What is the output of the code shown?
re.match('sp(.*)am', 'spam')
Correct Answer is : <_sre.SRE_Match object; span=(0, 4), match='spam'>