Exam-style question
Try this first
Which regular expression recognises strings over a and b that begin with a and end with b, with any number of a or b characters between them?.
- A.a(a|b)*b
- B.b(a|b)*a
- C.(a|b)*ab
- D.a*b*
Model answer
What a good answer should say
- a(a|b)*b
Explanation
Why this works
The initial a requires the string to begin with a, the final b requires it to end with b, and (a|b)* allows zero or more a or b characters in between.
Common mistake
No common mistake is linked to this question yet.
