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.
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$/
[^ab]*
This probably should do the trick. This says the string should not have any a or b. ^ is the symbol for negation.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.