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

I want Regular Expression for language L defined over {a,b} and L does not contain substring 'bbb'. I tried something but could not get proper answer.

## marked as duplicate by Raphael♦Mar 28 '18 at 10:09

We can decompose every string over $\{a,b\}$ as a sequence of runs: $$a^{n_1} b^{n_2} a^{n_3} b^{n_4} \ldots \text{ or } b^{n_2} a^{n_3} b^{n_4} a^{n_5} \ldots,$$ where $n_1,n_2,n_3,n_4,\ldots \geq 1$. In our case the constraint is $n_2,n_4,n_6,\ldots \leq 2$.
Let us start with the identity $$(a+b)^* = (a^+b^+)^*a^* + (b^+a^+)b^*,$$ which corresponds to the description above.
Can you think of a way to modify it so that all powers of $b$ are at most 2?