The density of $C[0,1]$ in $L^p[0,1]$ is shown here by showing we can approximate characteristic functions in the uniform norm (and consequently $L^p$ norm) by a continuous function, i.e. we want to show that
$$\forall\varepsilon>0\quad\forall E\in\mathfrak{M}([0,1])\quad\exists f\in C([0,1])\quad \Vert f-\chi_E\Vert<\varepsilon $$ The answer proceeds by using the regularity of the Lebesgue measure to find a closed set $F$ and an open set $U$ such that, $F\subset E\subset U$ with $\mu(U\setminus F)<\varepsilon$ and claiming that the desired $f\in C([0,1])$ is $$ f(t)=\frac{d(t, [0,1]\setminus U)}{d(t, [0,1]\setminus U)+d(t,F)} $$ where $d(t, S)=\inf\{|t-s|:s\in S\}$ is the distance function.
I am trying to show that such an $f$ indeed works.
First of all, when $t \in F$ or $t \in [0,1]\setminus U$, we have $f(t)=\chi_E(t)$.
Thus, $f$ and $\chi_E$ only differ on $U\setminus F$. But how do I show their difference is at most $\epsilon$ there?
Edit: We are approximating in the $L^p$ norm, not the sup norm. The conclusion follows immediately now by observing $f$ and $\chi_E$ differ only on $U\setminus F$ which has measure at most $\epsilon$.