ACE-P-ALE1-04 practice question 35 of 35
Which character matches the end of a line in a regular expression?
Full set: 100 questionsIn regular expressions, the dollar sign ($) is a metacharacter known as an anchor. It asserts a position at the very end of a line or string. It does not match any character itself but rather the position following the last character in the line. This is fundamental for creating patterns that must appear at the end of a line, a common requirement when filtering command output in network operating systems like Arista EOS.
A. !: The exclamation mark is not a standard metacharacter for matching the end of a line; it is used in more advanced constructs like negative lookaheads.
B. ^: The caret symbol is an anchor that matches the beginning of a line, which is the direct opposite of what is being asked.
D. ?: The question mark is a quantifier, indicating that the preceding character or group should appear zero or one time.
1. The Open Group Base Specifications Issue 7, 2018 edition (IEEE Std 1003.1-2017), Chapter 9, Regular Expressions, Section 9.3.6, "ERE Anchor Operators". This standard, which defines the behavior of tools like grep used in Arista EOS, states: "The ( '$' ) shall be an ERE anchor. The '$' shall match the end of the string..."
2. Arista Networks, EOS 4.31.1F Manual, Section: "Command-Line Interface", Subsection: "Filtering show Command Output". This documentation describes the use of the grep utility for filtering command output. The grep command implements the POSIX standard for regular expressions, where $ matches the end of a line.
3. MIT, "The Missing Semester of Your CS Education" Courseware (2020), Lecture 2: "Shell Tools and Scripting". The lecture notes on regular expressions explicitly state: "^ matches start of line, $ matches end of line". This confirms the standard usage of these anchors in a command-line context.
Keep practicing
Take the free ACE-P-ALE1-04 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other ACE-P-ALE1-04 practice questions
- Question 1When using the sudo command to run something as root, which password is required?
- Question 2Which utility can be used to remove sections or columns of each line of input?
- Question 3The ps –ef command is from which UNIX variant?
- Question 4In file globbing, which symbol matches any single character?
- Question 5If the system is swapping, what can be done to alleviate the problem?
- Question 6When scripting in bash, it is recommended to always use which symbols around your variabl…
