Can an open subset of an affine variety and the variety itself have isomorphic rings of regular functions? Let $X \subseteq \mathbb A^n_K$ be irreducible and closed (in the Zariski topology), $U \subseteq X$ open. Is $\mathcal O_X(X)$ the ring of rational and regular functions (which we know is isomorphic to the polynomial functions ring, since $X$ is an affine variety) isomorphic to $\mathcal O _U (U)?$
It looks to me it isn't, since for example $1/x$ is rational and regular on $\mathbb A^1 \setminus 0,$ while it isn't regular on the whole $\mathbb A ^1$. But who assures that there isn't some kind of strange isomorphism (here intended as isomporhism of $K$-algebras) which sends $1/x$ in some polynomial function?
 A: 1) If $X$ is a locally noetherian normal scheme,  $F\subset X$  a closed subset of codimension at least $2$ and $U=X\setminus F$, then the restriction morphism $$\mathcal O(X)\stackrel {\cong}{\to} \mathcal O(U)$$ is an isomorphism.
This the analogue of a much earlier result of Hartogs in the holomorphic context and is the geometric reflexion of the algebraic formula $$ A=\cap_{ht(\mathfrak p)=1} A_\mathfrak p   $$ where $A$ is a normal noetherian domain and $\mathfrak p$ runs through the height $1$ primes of $A$. 
2) The above result is completely false if $F$ is of codimension one.
For example if $A$ is a domain and $f\in A$ is non invertible, the restriction morphism $$\mathcal O(\operatorname {Spec}(A))=A \hookrightarrow \mathcal O(\operatorname {Spec}(A)\setminus V(f))=A_f$$ cannot be surjective since the function $\frac 1f \in A_f$ is not in $A$ . 
3) So in particular the answer to your question is:
The ring of regular functions on $\mathbb A^n_K\setminus F$ (where $F$ is a closed subvariety) is the polynomial ring $K[T_1,...,T_n]$ if and only if $F$ has codimension $\geq 2$.
