Constructing a regular expression based on this language

43 Views Asked by At

{w : w has at least two a’s and an odd number of b’s}

I'm having trouble wrapping my head around how to get every single possible outcome based on this language. An odd number of b's is more or less ((bb)b), at least 2 a's is just aa(a*). I know this is not strictly relevant to the final regular expression, it's just how I'm thinking about the language.

Basically I can't figure out the expression for this language. If you need at least 2 a's, then I imagine you'd need 2 a's with no attached kleene star.

Additionally, how do you guarantee an odd number of b's without resorting to something like ((bb)b)?

Actually I can't even figure out where to start with this problem. Writing this question has confused me further.

EDIT:

I've thought of a possible solution:

(a+(bb)*b)*a(a+(bb)*b)*a(a+(bb)*b)*

but this is perhaps a little inelegant