Which operator in a regular expression matches the preceding character either zero or one time?

Prepare for the LPI Linux Essentials 010-160 Test. Study with flashcards and multiple choice questions, each question offers hints and explanations. Get ready to ace your exam!

The operator that matches the preceding character either zero or one time is the question mark (?). This means that when this operator is used in a regular expression, it allows for the preceding character or group to be optional. For instance, if the regular expression is "a?", it will match either an "a" or nothing at all. This characteristic of the question mark makes it particularly useful in cases where a particular character may or may not be present in the string being searched.

In contrast, the asterisk (*) matches the preceding character zero or more times, which means it can match an empty sequence as well as multiple instances of the character. The plus sign (+) matches the preceding character one or more times, requiring at least one occurrence of the character to match. The period (.) is a wildcard that matches any single character, but does not relate to the concept of optionality in the same way that the question mark does.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy