As you saw in the previous lesson, the Kleene star and plus allow us to match repeated characters in a line.
Another quantifier that is really common when matching and extracting text is the ? (question mark) metacharacter which denotes optionality. This metacharacter allows you to match either zero or one of the preceding character or group. For example, the pattern ab?c will match either the strings "abc" or "ac" because the b is considered optional.
Similar to the dot metacharacter, the question mark is a special character and you will have to escape it using a slash \? to match a plain question mark character in a string.
In the strings below, notice how the the plurality of the word "file" depends on the number of files found. Try writing a pattern that uses the optionality metacharacter to match only the lines where one or more files were found.
|match||1 file found?|
|match||2 files found?|
|match||24 files found?|
|skip||No files found.|
We can use the meta-character '\d' to match the number of files and use the expression \d+ files? found\? to match all the lines where files were found.
Note that the first question mark applies to the preceding 's' character (for plurality), and the actual question mark at the end must be escaped to match the text.