This result is presented on page 14 of Foundations of Modern Macroeconomics. The key is to total differentiate both expressions.
Start with the supply of labor:
\begin{gather}
W/P^e = g(N^S) \\
d(W/P^e) = d\Big( g(N^S) \Big) \\
\frac{1}{P^e} dW - \frac{W}{(P^e)^2}dP^e = g_NdN^S \\
dN^S = \frac{1}{g_N}\frac{dW}{P^e} - \frac{1}{g_N}\frac{W}{P^e}\frac{dP^e}{P^e} \\
dN^S = \frac{1}{g_N}\frac{dW}{P^e} - \frac{g(N^S)}{g_N}\frac{dP^e}{P^e}, \quad \text{where} \quad W/P^e = g(N^S) \\
dN^S = \frac{1}{g_N}\frac{g(N^S)}{W}dW - \frac{g(N^S)}{g_N}\frac{dP^e}{P^e} \\
dN^S = \frac{g(N^S)}{g_N} \bigg[ \frac{dW}{W} - \frac{dP^e}{P^e} \bigg] \\
\frac{dN^S}{N^S} = \frac{g(N^S)}{N^Sg_N} \bigg[ \frac{dW}{W} - \frac{dP^e}{P^e} \bigg]
\end{gather}
To derive the expression for the demand of labor, one can follow a similar process (I will ommit the superscript $N^D$ for simplicity, but we know we are talking about labor demand). Recall that the FOC of the firm's problem is given by:
\begin{gather}
PF_N(N,\bar{K}) = W \\
F_N(N,\bar{K}) = \frac{W}{P} \\
d\Big( F_N(N,\bar{K}) \Big) = d\Big( W/P \Big) \\
F_{NN}dN + F_{NK}d\bar{K} = \frac{1}{P}dW - \frac{W}{P^2}dP \\
F_{NN}dN + F_{NK}d\bar{K} = F_N\frac{dW}{W} - F_N\frac{dP}{P} \\
F_{NN}dN = F_N \bigg[ \frac{dW}{W} - \frac{dP}{P} \bigg] - F_{NK}d\bar{K} \\
dN = -\frac{F_{NK}}{F_{NN}}d\bar{K} + \frac{F_N}{F_{NN}}\bigg[ \frac{dW}{W} - \frac{dP}{P} \bigg] \\
\frac{dN^D}{N^D} = -\frac{F_{NK}}{N^DF_{NN}}d\bar{K} + \frac{F_N}{N^DF_{NN}}\bigg[ \frac{dW}{W} - \frac{dP}{P} \bigg] \\
\frac{dN^D}{N^D} = \frac{d\bar{K}}{\bar{K}} + \frac{F_N}{N^DF_{NN}}\bigg[ \frac{dW}{W} - \frac{dP}{P} \bigg], \quad \text{where} \quad KF_{NK} = -NF_{NN}
\end{gather}