My answer : (0+1)* 0 (0+1)* 0 (0+1)*
Why is this incorrect? Can somebody explain to me what the correct answer is and why?
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.Sign up to join this community
It's incorrect for example because it does not match the string $100$.
The two zeroes would have to match the two zeroes in your regexp that are ouside the parentheses. Because of that, $(0\!+\!1)^*$ would have to match $1$, but it doesn't. That's because $(0\!+\!1)^*$ implies there has to be at least one zero for every $1$.
I think the regular expression that you meant is:
$$(0|1)^* 0 (0|1)^* 0 (0|1)^*.$$