Proof (Lusin)

The condition $\|g\|_\infty \leq \|f\|_\infty$ can be dropped: if $\|f\|_\infty = 0$, just take $g = 0$. Otherwise define $$ \begin{align*} ϕ: \C &\to \C \\ z &\mapsto \begin{cases} z, &|z| \leq \|f\|_\infty, \\ \frac{\|f\|_\infty}{|z|} z, &|z| \geq \|f\|_\infty, \end{cases} \end{align*} $$ which is continuous with $\|ϕ\|_\infty = \|f\|_\infty$. Given some continuous $g: E\to \C$ such that $g|_K \equiv 0$ and $μ(\sb{x\in E}{g(x) \neq f(x)}) < ε$, let $$ \begin{align*} \tilde g = ϕ \circ g \end{align*} $$ which is still continuous with $\tilde g|_K \equiv 0$. Moreover $$ \begin{align*} &μ(\sb{x\in E}{\tilde g(x) \neq f(x)}) \\ ={}& μ(\sb{x\in E}{g(x) \neq f(x)}) + μ(\sb{x\in E}{\tilde g(x) \neq g(x) = f(x)}) \\ <{}& ε + μ(\sb{x\in E}{|f(x)| > \|f\|_\infty}) \\ ={}& ε. \end{align*} $$

(See also Linear Analysis sheet 3 Q1)

$f = \mathbb{1}_A$

Suppose $f = \mathbb{1}_A$ for some measurable $A$ and $K$ is a closed set disjoint from $A$.

[[FILE NOT FOUND: Take]] $U$ open in $E$ and $L$ compact in $E$ such that $L \subseteq A\subseteq U$ and $μ(U \setminus L) < ε$. Replace $U$ with $U \setminus K$ (still open) to assume $U$ and $K$ are disjoint. Then take $g$ to be any continuous function $E\to [0,1]$ such that $g|_L = 1$ and $g|_{E \setminus U} = 0$, e.g. $$ \begin{align*} g(x) = \frac{d(x, E\setminus U)}{d(x, E\setminus U) + d(x,L)}. \end{align*} $$

$f: E\to \C$

Split $f = \Re f + \Im f$ to reduce to $f: E\to \R$. Split $f = f_+ + f_-$ to reduce to the case $f: E\to [0, \infty)$. Moreover compose with an increasing homeomorphism $[0, \infty)\to [0,1)$ to reduce to the case $f: E\to [0,1]$. Take $K$ to be any closed set where $f|_K \equiv 0$.

Choose any consistent binary expansion of numbers in $[0,1]$ and let $A_n$ be the set of $x\in E$ where the $n$-th digit in the binary expansion of $f(x)$ is 1. Then $$ \begin{align*} f = \sum_{n=1}^{\infty} 2^{-n} \mathbb{1}_{A_n} \end{align*} $$ and moreover $K$ and $A_n$ are disjoint for all $n$.

Using the previous case, let $g_n: E\to [0,1]$ be a continuous function such that $g_n|_K \equiv 0$ and $$μ(\sb{x\in E}{g_n(x) \neq \mathbb{1}_{A_n}(x)}) < ε/2^n.$$ Define $$ \begin{align*} g = \sum_{n=1}^{\infty} 2^{-n} g_n. \end{align*} $$ Then $g|_K \equiv 0$ and $$ \begin{align*} μ(\sb{x\in E}{f(x)\neq g(x)}) \leq \sum_{n=1}^{\infty} μ(\sb{x\in E}{g_n(x) \neq \mathbb{1}_{A_n}(x)}) < ε. \end{align*} $$