Language of all the binary words that contain $010$ at least twise

57 Views Asked by At

I need to write a regular expertion for the language of all the binary words that contain $010$ at leasr twise, note that $101010$ should be accept too because $1\color{blue} {010}10$ and $101\color{green} {010}$

My try: $(1+0)^*(010)(10)(1+0)^*+(1+0)^*(010)(1+0)^*(010)(1+0)^*$

My attempt is correct?

1

There are 1 best solutions below

0
On BEST ANSWER

As Brian M. Scott said you answer is correct.

If you want a "simpler" regular expression this one is correct too: $$(0+1)^*\color{red}{010}\color{blue}{((1+0)^*0)^*}\color{green}{10}(1+0)^*$$ Hand waving to show the correctness goes as follow: the red part match the first 010 the green part the end of the second 010. and between them there can be any words either empty or ending by a 0 matched by the blue part.