Regular expressions matching given string

97 Views Asked by At

I had an exam and there was an ambiguous question that confused all the students. The question was: What is the regular expression that accepts the string aaaabbbb?

And the options were (we had to choose one option only):

  1. aa*bb*
  2. a*b*
  3. (a+b)*
  4. (a+b)*(a+b)*

I expected the answer to be (a+b)* as it the most general regular expression that accepts all the strings over the alphabet {a, b}.

0

There are 0 best solutions below