# Regular expressions for words avoiding aaa,bbb,ccc [duplicate]

I need to write a regular expression for all words over $\{a,b,c\}$ not containing $aaa$, $bbb$ or $ccc$. Will appreciate any help. Note: this is not homework.

• Try first not allowing repeats of size 2, and then see if you can extend this idea to your case. You can also construct a DFA/NFA and convert it to a regular expression. – Yuval Filmus May 22 '17 at 19:16
• Welcome to CS.SE! We get asked this kind of question a lot, so we've written some general reference material for you: cs.stackexchange.com/q/45570/755, cs.stackexchange.com/q/1331/755. Please study that material, then try applying it to your problem, and see if you can solve it. If not, edit your question to show the approaches you've tried, the steps you've taken, what progress you made, and where specifically you got stuck. – D.W. May 22 '17 at 21:30