Now, I have three strings to be matched by a single re -- 'a', 'ab','ac' I suppose one correct re should be 'a[bc]?', but it seems not correct. What is the correct one?
I try it in grep command. And it seems that there is no '?' in grep's regex. So how to do this matching in grep?
Thanks to @anubhava, I now can match all these three strings by:
grep -E 'a[bc]?' <file>
However, this expression also matches 'ad'.
In fact, I want to match all these situation: 'a','abc','ab','ac' but do not want to match 'ad' or 'ae'