ExpertRefresh

Egrep / Optional items  

1) A regex containing optional metacharacter is always successful?




2) What is one of the main uses of parantheses?




3) Which character is optional in colou?r






Question mark
Question mark in /colou?r/ means "optional". It is placed after the character that is optional (might appear but isn't required).
Always successful
The u? part is always successful. This isn't to say that any regex that contains ? is always successful. For example, in /colou?r/ against "semicolon", both "colo" and "u?" are successful, but r fails, so the whole regex fails.
Paranthesses
Grouping for ? (and other similar metacharacters) is one of the main uses of parantheses. For example /4th|4/ can be simplify to /4(th)?/


References