example of regular element of $\mathcal{O}_X(X)$ restricting to non-regular element on some stalk $\mathcal{O}_{X,x}$ A regular element of a commutative ring $A$ is an element that is not a zero-divisor. The set of regular elements $R(A)$ of $A$ form a multiplicative subset of $A$.
Let $X$ be a scheme, clearly we have
$$\{f\in \mathcal{O}_{X}(X)|f_x\in R(\mathcal{O}_{X,x}),\forall x\in X\}\subset R(\mathcal{O}_{X}(X))$$
And it's an equality if $X$ is affine or integral.
Therefore I want to ask for an example s.t. the above containment is strict.
 A: Let $Y=\operatorname{Spec}k[x,y]/(xy)$ (over some field $k$) and let $X$ be obtained from $Y$ by completing one of the two lines that make up $Y$.  So, $X$ is a union of a copy of $\mathbb{P}^1$ and a copy of $\mathbb{A}^1$ that intersect at a point.  Any element of $\mathcal{O}_X(X)$ is constant on the copy of $\mathbb{P}^1$ and so $\mathcal{O}_X(X)\cong k[x]$ by restriction to the copy of $\mathbb{A}^1$.  However, locally at the intersection point of the two lines, the global section $x$ becomes a zero divisor since $xy=0$.
A: I have found an answer in mathoverflow, see this link. I will give a proof from my understanding.
Let $k$ be a field, consider a $k$-rational point $P_1$ in $\mathbb{A}^1_k$ and a $k$-rational point $P_2$ in $\mathbb{P}^1_k$. They give rise to closed immersions $i_1:\mathop{\mathrm{Spec}}k\to \mathbb{A}^1_k,i_2:\mathop{\mathrm{Spec}}k\to \mathbb{P}^1_k$. We glue $\mathbb{A}^1_k$ and $\mathbb{P}^1_k$ by identifying $P_1$ and $P_2$, using Corollary 3.7 from the paper Gluing schemes and a scheme without closed points, we obtain a scheme $X=(\mathbb{A}^1_k\cup \mathbb{P}^1_k)/(P_1\sim P_2)$.
In page 2 of the above paper, we know that $\mathcal{O}_X(X)$ is the subring of the product $\mathcal{O}(\mathbb{A}^1_k) \times \mathcal{O}(\mathbb{P}^1_k)$ consisting of pairs $(f,g)$ s.t. $i_1^\#(f)=i_2^\#(g)$. Since $\mathcal{O}(\mathbb{A}^1_k)=k[x]$ and $\mathcal{O}(\mathbb{P}^1_k)=k$, $i_1^\#$ is determined by $i_1^\#(x)$ and $i_2^\#$ is just the identity map on $k$, we have
$$\mathcal{O}_X(X)=\{(f(x),c)\in k[x]\times k\ |\ f(i_1^\#(x))=c\}=k[x-i_1^\#(x)]\cong k[y].$$
Then $y\in \mathcal{O}_X(X)$ is a regular element and it is zero at all stalks in $\mathbb{P}^1_k \subset X$.
