mif
09-23-02, 03:42 PM
Hi I am new in learning regular expressions and having trouble understanding one example...
it is where you have to write a regular expression for the set of strings containing no more than three a's in a row. The alphabet
is {a,b}.
So what i thought doing is: after you get 3 a's in a row, they have to be separated by at least one b..also, you have 3 cases:
a
aa
aaabb*
so i came up with this regular expression:
b*(a|aa|aaabb*)*bb*
but it does not accept the string aaa.
so i am stuck..is my reasoning right at least?
anyone who is good at regular expressions?
Thanks a lot guys!:)
it is where you have to write a regular expression for the set of strings containing no more than three a's in a row. The alphabet
is {a,b}.
So what i thought doing is: after you get 3 a's in a row, they have to be separated by at least one b..also, you have 3 cases:
a
aa
aaabb*
so i came up with this regular expression:
b*(a|aa|aaabb*)*bb*
but it does not accept the string aaa.
so i am stuck..is my reasoning right at least?
anyone who is good at regular expressions?
Thanks a lot guys!:)