Extending functions to homeomorphism Is there a homeomorphism $f:(0,1) \to \mathbb{R}$ such that $f$ (co)restricts to a homeomorphism $f:(0,1)\cap \mathbb{Q} \to \mathbb{Q}$?  
I am a bit rusty in general topology, but I think that $\mathbb{Q} \cong (0,1) \cap \mathbb{Q}$ and $ \mathbb{R}-\mathbb{Q} \cong (0,1) - \mathbb{Q}$. So there wouldn't be any easy contradiction. So is there another strategy or a counterexample to (dis)prove the statement?
More generally, given a space $X$ and $Y,Z\subset X$ such that $|X|=|Z|$, is there a homeo sending $Y$ to $Z$? Of course it is false in general (e.g $Y$ has some topological property that $Z$ hasn't). But is there some conditions on $Y$ and $Z$ (and $X$?) such that there is such homeomorphisms ?
 A: Sure.  Take any order-isomorphism $f_0:(0,1)\cap\mathbb{Q}\to\mathbb{Q}$; then taking Dedekind completions of both sides, $f_0$ extends uniquely to an order-isomorphism $f:(0,1)\to\mathbb{R}$ which is then such a homeomorphism.  More explicitly, any piecewise-linear homeomorphism $f:(0,1)\to\mathbb{R}$ such that the endpoints of the linear pieces in both the domain and codomain are all rational will map $(0,1)\cap\mathbb{Q}$ to $\mathbb{Q}$.
As for your general question, as you observe, there are easy counterexamples, and I doubt there is anything you can say with much generality.  Really, the case where there does exist a homeomorphism of $X$ sending $Y$ to $Z$ is the exception, not the rule.
A: For a constructive example, first here's a homeomorphism $g:(0, 1)\to \mathbb{R}_{+}$ whose restriction is a homeomorphism $(0, 1)\cap \mathbb{Q} \to \mathbb{Q}_{+}$:
$$\begin{align}
g(x) &= \frac {x} {1-x} \\
&= \frac {1} {{\frac {1} {x}} - 1} \\
\end{align}
$$
This $g$ easily extends to a homeomorphism $h:(-1, 1)\to \mathbb{R}$ which maps rationals to rationals: $h(x) = -g(-x)$ for $x < 0$, and $g(0) = 0$. Composing h with $x \mapsto 2x - 1: (0, 1) \to (-1, 1)$ gives a homeomorphism $f$ as desired.
As for your more general inquiry about homeomorphisms that in some sense preserve subspaces, perhaps there are results that generalize this case,  but that's a question for serious topologists. The Tietze Extension Theorem comes to mind, but it's only a vague similarity; it wouldn't help here, for example.
