I'm trying to find a regular expression for the following language:
$$L=\{x0y : \text{$x$ contains same number of 0's as $y$ contains 1's}\}. $$
I'm trying to find a regular expression for the following language:
$$L=\{x0y : \text{$x$ contains same number of 0's as $y$ contains 1's}\}. $$
The trick is to write $L$ as a different language. Let's consider the following similar language $$ L' = \{ xy \in \{0,1\}^* : \#_0(x) = \#_1(y) \}, $$ where $\#_0(x)$ is the number of 0's in $x$.
I claim that $L' = (0+1)^*$. Indeed, let $w = w_1\ldots w_n$ be some arbitrary word, and define $\delta_w(i) = \#_0(w_1\ldots w_i) - \#_1(w_{i+1}\ldots w_n)$. The following properties are not hard to check:
This shows that $\delta_w(i) = 0$ for some $0 \leq i \leq n$, and so $w \in L'$.
Your case is very similar - I'll leave you to figure out the details.