# Regular expression of a language over {a,b,c} which does not contain substring bbb

I'm trying to figure out how to build a regular expression for a language that doesn't contain substring bbb. The alphabet is {a,b,c}. I'm trying to construct a DFA and convert to help me get the Regular Expression but still stuck as I found the DFA a bit complicated. I appreciate any help. Thanks!!!

Ok, here is the Regular Expression I've worked on to help me solve the above question. ac[(acb)* U (acbb)]ac*

Test: aaaa ccccc acbacbacb aaaaaaa ccccc (OK) aa acbb acbb acbb acbb cccccccc (OK)

But how about cab or cabb? I then modified the above expression to: ac[(acb)* U (acbb)* U (cab)* U (cabb)]ac*

I'm I heading to the right direction?

Thanks again!

• I generally find it easier to construct regular expressions first and then the DFA. – Jake Jul 6 '15 at 2:49
• possible duplicate of How to prove a language is regular? – D.W. Jul 6 '15 at 2:50
• @D.W. How is this duplicate? The answer you referenced appear to be very high level (generic). like how to program in java as opposed to how to write a linked list in Java. My question is how to write a specific regular expression for assuming a Regular Language. – GuyEpsilon Jul 6 '15 at 3:07
• We expect you to make a significant effort before asking here, including searching on this site and consulting the resources we already have here, and to show us in the question what you've tried. Your question is very basic. I recommend that you study the material found in that question, then work through the techniques there and apply it to your problem. I think you'll find that the techniques there will enable you to solve your own problem. If you're still stuck, edit the question to show how you worked through those techniques and where specifically you got stuck when applying them. – D.W. Jul 6 '15 at 3:09
• @D.W. I've added additional info to show how I've worked through the technique of using Regular Expression. Thanks! – GuyEpsilon Jul 6 '15 at 3:29

The following regular expression (where $\cdot$ stands for $a|b|c$) will match all strings with lengths divisible by 3 not containing the string $bbb$ and not starting with a b.
$((a|c)\cdot\cdot)^*$