I need help finding all strings not included in (a*b)*

223 views Asked by At

I'm doing this for homework. I need to write a regular expression for a language over (a, b) that includes all strings not included in a language (a*b)*

for example 'aaaaaaabaaaaaaaabaaaaaaabaaaabaaaaaaaaab' would work. So I'm looking for a regular expression for allll the strings which are not included in that.

Can you help me at least get on the right step to figure it out?

I know that a*b means as many a's as we want followed by one b. Then that whole sort as many times as we want.

3

There are 3 answers

1
Indu Devanath On
[^ab]*

This probably should do the trick. This says the string should not have any a or b. ^ is the symbol for negation.

1
Gabriele Petrioli On

It seems that your (a*b)* regular expression matches anything that ends in a b or is empty.

so a regular expression that matches anything that end in a seems to be the solution..

a$ or /a$/

0
AudioBubble On

You could iterate over the String and check for characters besides 'a' and 'b'. It seems chains of 'b's are allowed and the empty string are a part of the language, since the Kleene star allows for zero instances of the character.