- What is a regular expression in Python?
- Write a Python program to check that a string contains only a certain set of characters (in this case, a–z, A–Z, and 0–9).
- Which module in Python supports regular expressions?
a) re
b) regex
c) pyregex
d) None of the above - What does the re.match function do?
a) Matches a pattern at the start of the string
b) Matches a pattern at any position in the string
c) Such a function does not exist
d) None of the above - What is the output of the following?
Sentence: "we are humans"
Matched: re.match(r'(.*) (.*?) (.*)', sentence)
print(matched.group())
a) ('we', 'are', 'humans')
b) (we, are, humans)
c) ('we', 'humans')
d) 'we are humans'