No, it is not true. I'm going to describe everything in terms of commutative algebra, so take $X=Y=\operatorname{Spec} R$.
Let $G$ be the group $\mathbb Z \times \mathbb Z$ with the lexicographic ordering. Let $R$ be any valuation ring with value group $G$ and then $R$ has dimension $2$ since it has exactly three prime ideals, forming the chain:
$$\mathfrak m = \{ r \in R \mid v(r) \geq (0, 1) \} \supset \mathfrak p = \{ r \in R \mid v(r) = (a, b) \mbox{ where } a \geq 1\} \supset 0,$$
where $v$ denotes the valuation. Let $t$ be any element of valuation $(0,1)$ so that the vanishing set of $t$ is the single closed point $\mathfrak m$. Thus, $1/t$ is a regular function on $U = X \setminus \mathfrak m$, but $1/t$ is not in $R$ even though $\mathfrak m$ has codimension 2.
I think about the result for Noetherian normal rings in terms of two separate results: First, if $R$ is a Noetherian domain, then $R$ is the intersection of $R_{\mathfrak p}$ as $\mathfrak p$ ranges over all associated primes of principal ideals. Second, in a normal Noetherian domain, all associated primes of principal ideals have codimension 1 (this is condition S2 of Serre). I suspect that the first might generalize to non-Noetherian rings, provided that you have the right definition of associated prime. The second fails pretty much as badly as possible, since a single element can generate a prime ideal of arbitrary codimension, or even infinite codimension.