logo

Question detail

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?

Try the question, check the answer, then read the explanation to understand the curriculum point.

At a glance

MCQ

Type

practice

Style

Topic

Regular languages

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?.

  1. A.a(a|b)*b
  2. B.b(a|b)*a
  3. C.(a|b)*ab
  4. 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.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.