Regular Expressions – Regular Expression 00 or 11 Not Both

regular expressionsregular-language

Can anyone help me with this question: I know it before, but I have tried to solve it myself and didnt succeed.
what is the regular expression for this language: L=all words that have 00 or 11 but not both.

Thank you!

Best Answer

It will be the union of two languages: $$ A = \mbox{All words that have 00 but not 11} $$ and $$ B = \mbox{All words that have 11 but not 00} $$ A regular expression for a language that does not contain 11 can be of the form: $$(1+\epsilon)(01+0)*$$ Therefore, a regular expression for A could be: $$ (1+\epsilon)(01+0)* (00) (1+\epsilon)(01+0)* $$ And a regular expression for B could be similar.