Regular Expression - ? - matches zero or one of the previous single expression

The question mark (?) matches with zero or one occurrences of the previous single expression. In other words, it makes that character or expression optional.
Using round brackets can put several expressions together to be repeated. e.g. abc(def)?

Examples

Match line that contains colour or color:

colou?r
This would match the following:
colour
color
It would not match the following:
colouur

Computing Articles