Which statement about anchors is True ? Select one: a. The caret (^) and dollar
ID: 3586580 • Letter: W
Question
Which statement about anchors is True?
Select one:
a. The caret (^) and dollar sign ($) are anchors meaning they cause the match to occur if the regex is found at the beginning ($) or end (^) of a line.
b. The caret (^) and dollar sign ($) are anchors meaning they cause the match to occur if the regex is found at the beginning (^) or end ($) of a line.
c. The greater than (>) and less than (<) sign are anchors meaning they cause the match to occur if the regex is found at the beginning (>) or end (<) of a line.
d. The caret (>) and dollar sign ($) are anchors meaning they cause the match to occur if the regex is found at the beginning (>) or end ($) of a line.
Let's say that there was a text file called example.txt that contained the following lines of text:
pam
sam
pamelot
camelot
samelot
what would NOT be output if the following command was issued?
grep -h '[sp]am' example.txt
Select one:
a. samelot
b. pam
c. pamelot
d. camelot
e. sam
While running vim, which key do you press in command mode to search for text using a regular expression?
Select one:
a. e
b. q
c. r
d. /
e. x
What command should you use to find files whose interior text contains a particular phrase (like “Info 490”)?
Select one:
a. search
b. locate
c. which
d. find
e. grep
In POSIX regex (the version covered in TLCL), which fact about the backslash ( ) character is true?
Select one:
a. It is used to create meta sequences
b. All of these
c. It allows metacharacters to be escaped and treated as literals
d. It is a metacharacter
Explanation / Answer
NOTE: ANSWERS ARE GIVEN IN BOLD
answer is b.
b. The caret (^) and dollar sign ($) are anchors meaning they cause the match to
occur if the regex is found at the beginning (^) or end ($) of a line.
for e.g:
sh-4.4$ grep -h '^sa' example.txt
sam samelot
answer is d.
d.camelot
sh-4.4$ grep -h '[sp]am' example.txt
pam
sam
pamelot
samelot
d./
/ and ? are used to execute the regular expressions in vi.
e.grep
grep is used to find the words in a file
sh-4.4$ cat > example2.txt
this is a sample text
Info 490 is a word
to search
in the world
^C
sh-4.4$ grep 'Info 490' example2.txt
Info 490 is a word
b. All of these
"" is a special character, is also called meta character, is used to create meta sequences, is used to escape some
characters
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.