TITLE: Extension of regular function
QUESTION [5 upvotes]: This is an exercise in Hartshorne's book.

For a quasi projective variety $Y$ with dimension $\geq 2$ and $p \in Y$ a normal point,
  if $f$ is regular on $Y-\{p\}$ then $f$ can be extended to a regular function on $Y$.

I want to get some hints to prove this problem....

REPLY [4 votes]: Since the problem is local around $p$, you can assume that $Y=Spec(A)$ where $A$ is a noetherian domain  (quasi-projectiveness is irrelevant). 
Clearly, every point $\mathfrak q \in Spec(A)$ of height one is distinct from $p$ (since $\mathfrak q$ it corresponds to a subvariety of codimension $1$). So every function $f$ defined  on $Spec(A)\setminus \lbrace p\rbrace $ is defined  at $\mathfrak q $.
You can  then conclude that $f\in A$, that is $f$ extends regularly through $p$, thanks to the formula valid for a noetherian normal domain  (Matsumura, Commutative ring theory, Theorem 11.5, page 81)
$$ A=\bigcap_{ht(\mathfrak q)=1}    A_ \mathfrak q              $$
A general result in this vein is that if $X$ is a locally noetherian normal integral scheme and $Y\subset X$  a closed subset of codimension $\geq 2$, the restriction morphism $\mathcal O_X(X)\to O_X(X\setminus F)$ is bijective.