0

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!

GuyEpsilon
  • 21
  • 3
  • 1
    I generally find it easier to construct regular expressions first and then the DFA. – Jake Jul 06 '15 at 02:49
  • @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 06 '15 at 03: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 06 '15 at 03:09
  • @D.W. I've added additional info to show how I've worked through the technique of using Regular Expression. Thanks! – GuyEpsilon Jul 06 '15 at 03:29
  • There are a whole bunch of techniques on that page. I don't see any evidence that you've tried any of the following: using closure properties; building a scanner that uses only a fixed amount of memory; using the property described in Rick Decker's answer. Any of those yields an answer to your question. You might need to spend some quality time studying this material on your own. 21 minutes is most likely not going to be enough. – D.W. Jul 06 '15 at 03:40

1 Answers1

1

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)^*$

Can you modify this to get the expression you want?

Jake
  • 3,810
  • 19
  • 35