1
$\begingroup$

Let's assume I have the following regular language:

L = {1,0}*{010}{1,0}*

I would like to convert this to regex for a program. Would the equivalent regular expression for this be:

((0+1)*(010)(0+1)*) or ((0+1)*(010)(0+1)*)*

Or is it something else completely?

$\endgroup$

1 Answer 1

1
$\begingroup$

If I understand correctly, the language is $\{0,1\}^* . \{010\} . \{0,1\}^*$ (where $.$ is concatenation of languages). Then the first regular expression, i.e., $(0+1)^*(010)(0+1)^*$, is correct.

The second one describes different language. The iteration of the expression (i.e., the outer parentheses) would match the empty string, while language $L$ requires at least $010$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.