So Σ = {a, b}, I need to find a regular expression representing all strings that contain either ba or abb. Here's what I got, but I wonder if it's correct.
(ab)(baUabb)(ab)(baUabb)(ab)*
It seems to be that it's a bit too long.
Would appreciate any help!
Note that the patterns
abbandbacover almost all possibilities for what can happen when you switch from one letter to the other. The only case that's not covered are strings likeaaaaaaab, specifically with only a singlebat the end. With that in mind, I was thinkingWhich looks for either of the two following patterns:
a, then ab, then at least one more letterb, then ana, then the rest of the string