Multiple choice technology programming languages

To search a string at the end of the line use

  1. / <str>*

  2. /<str>$
  3. /<str>&

  4. None

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In vi, the $ character anchors a search pattern to the end of a line. Using '/str$' searches for lines ending with 'str'. Option A's asterisk (*) is a regex wildcard not used for line anchoring, and option C's ampersand (&) is not a line-anchoring character in vi searches.

AI explanation

In vi/ex-style regular expression search syntax, '$' is the anchor that matches the end of a line, so /$ finds occurrences of only when they appear at the end of a line. '' is a quantifier meaning zero-or-more of the preceding character, not a position anchor, so / is not an end-of-line search. '&' has no special end-of-line meaning in this context (it's used in substitution replacement text to mean 'the matched text', not in search patterns for position). This is standard regex/vi anchor knowledge.