Google IT Automation with Python Professional Certificate • STUDY MODE
REGULAR EXPRESSIONS
QUESTION 1 OF 8
When using regular expressions, which of the following expressions uses a reserved character that can represent any single character?
Nailed it! The dot (.) represents any single character.
A
re.findall(^un, text)
B
re.findall(f.n, text)Correct Answer
C
re.findall(f*n, text)
D
re.findall(fu$, text)
QUESTION 2 OF 8
Which of the following is NOT a function of the Python regex module?
Keep it up! The grep command utilizes regular expressions on Linux, but is not a part of the standard re Python module.
A
re.search()
B
re.match()
C
re.grep()Correct Answer
D
re.findall()
QUESTION 3 OF 8
The circumflex [^] and the dollar sign [$] are anchor characters. What do these anchor characters do in regex?
Nailed it! the circumflex and the dollar sign specifically match the start and end of a line.
A
Match the start and end of a word.
B
Match the start and end of a lineCorrect Answer
C
Exclude everything between two anchor characters
D
Represent any number and any letter character, respectively
QUESTION 4 OF 8
When using regex, some characters represent particular types of characters. Some examples are the dollar sign, the circumflex, and the dot wildcard. What are these characters collectively known as?
Awesome! Special characters, sometimes called meta characters, give special meaning to the regular expression search syntax.
A
Special charactersCorrect Answer
B
Anchor characters
C
Literal characters
D
Wildcard characters
QUESTION 5 OF 8
What is grep?
Right on! The grep command is used to scan files for a string of characters occurring that fits a specified sequence.
A
An operating system
B
A command for parsing strings in Python
C
A command-line regex toolCorrect Answer
D
A type of special character
QUESTION 6 OF 8
Which of the following demonstrates how regex (regular expressions) might be used?
Awesome! Regex is a search query that matches the regular expression pattern you've specified.
A
Recognize an image
B
Calculate Pi
C
Find strings of text that match a patternCorrect Answer
D
Multiply and divide arrays
QUESTION 7 OF 8
Rather than using the index() function of the string module, we can use regular expressions, which are more flexible. After importing the regular expression module re, what regex function might be used instead of standard methods?
Great job! Using the re module provides more robust solutions, not limited to just re.search().
A
re.search()Correct Answer
B
re.index()
C
re.pid()
D
re.regex()
QUESTION 8 OF 8
Using the terminal, which of the following commands will correctly use grep to find the words “sling” and “sting” (assuming they are in our file, file.txt)?
Nice work! In regex, a dot is a wildcard, so it can represent any character. This command will print both “sting” and “sling”, if they are in the file.
When using regular expressions, which of the following expressions uses a reserved character that can represent any single character?
Nailed it! The dot (.) represents any single character.