For a regular expression (a | b)*, can I write this string: aaaaaaabbbbbbbbbbbabababbb. I was thinking this means that when I choose a, I can have multiple a's and then I can choose b too after choosing multiple a's. Or is it that once I chose a, I cannot go back and choose b after finishing with a?
2026-03-28 00:36:44.1774658204
On
Discrete Math Quick Regular Expression question!
928 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
3
There are 3 best solutions below
2
On
Regular expression (a | b)* indicates that you can choose any number (including 0) of a and b and it doesn't matter whichever is the sequence i.e. you can start with a or b. The second one is ab which means it should or should not start with a (a's occurrence can be 0 or more but once you moved to b there is no turning back to a.
Your first interpretation is correct. The second one would correspond to the regular expression $a^*b^*$. But in both cases, don't forget to consider the empty word as well...