Which of the following strings match [BD][ae][ae]?d
?
String | Bed | Bead | Dead | aed | Ba?d | Ded | Bea |
---|---|---|---|---|---|---|---|
Match or Reject? |
Match | Match | Match | Reject | Reject | Match | Reject |
The RE [BD][ae]\?d
matches the strings
Ba?d ,
Be?d ,
De?d ,
and
Da?d .
The question mark has been "escaped" with the backslash, and so does not function in its special role but merely
stands for itself.
An automaton for a?bc
requires an optional state for the transition that is made when an optional 'a' is consumed.
The state q1 is reached when the optional 'a' is consumed. There then must be a transition out of that state for the following 'b'.
Could we make the transition for 'a' out of state q0 loop back to q0? Would this avoid the need for state q1?