QuiztudyPREMIUM
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 AnswerC
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 AnswerD
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 AnswerC
Exclude everything between two anchor charactersD
Represent any number and any letter character, respectivelyQUESTION 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 AnswerB
Anchor charactersC
Literal charactersD
Wildcard charactersQUESTION 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 systemB
A command for parsing strings in PythonC
A command-line regex toolCorrect AnswerD
A type of special characterQUESTION 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 imageB
Calculate PiC
Find strings of text that match a patternCorrect AnswerD
Multiply and divide arraysQUESTION 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 AnswerB
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.
A
user@ubuntu:~$ grep s+ing /usr/file.txtB
user@ubuntu:~$ grep sting+sling /usr/file.txtC
user@ubuntu:~$ grep s.ing /usr/file.txtCorrect AnswerD
user@ubuntu:~$ grep(s.ing) /usr/file.txtReady to test your recall?
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)
C
re.findall(f*n, text)
D
re.findall(fu$, text)
How confident are you in this answer?