nerdexam
Linux_Foundation

LFCS · Question #798

What does the ? symbol within regular expressions represent?

The correct answer is C. Match the preceding qualifier zero or one times. In regular expressions, the ? symbol acts as a quantifier, matching the preceding element zero or one time, making it optional.

Submitted by minji_kr· Apr 18, 2026Essential Commands

Question

What does the ? symbol within regular expressions represent?

Options

  • AMatch the preceding qualifier one or more times.
  • BMatch the preceding qualifier zero or more times.
  • CMatch the preceding qualifier zero or one times.
  • DMatch a literal ? character.

How the community answered

(32 responses)
  • A
    3% (1)
  • C
    91% (29)
  • D
    6% (2)

Why each option

In regular expressions, the `?` symbol acts as a quantifier, matching the preceding element zero or one time, making it optional.

AMatch the preceding qualifier one or more times.

Matching the preceding qualifier one or more times is represented by the `+` symbol in regular expressions.

BMatch the preceding qualifier zero or more times.

Matching the preceding qualifier zero or more times is represented by the `*` symbol in regular expressions.

CMatch the preceding qualifier zero or one times.Correct

The `?` quantifier in regular expressions signifies that the character, group, or class immediately preceding it can occur zero times or one time, essentially making that element optional in the match.

DMatch a literal ? character.

To match a literal `?` character in a regular expression, it must be escaped with a backslash, i.e., `\?`.

Concept tested: Regular expression quantifiers (?)

Source: https://www.gnu.org/software/grep/manual/grep.html#Regular-Expressions

Topics

#Regular Expressions#RegEx#Pattern Matching#Essential Commands

Community Discussion

No community discussion yet for this question.

Full LFCS Practice