I want to find the weak derivative of $y=|x^2-1|$. We know
$$ y = \begin{cases} x^2-1, & |x|>1 \\ 1 - x^2, & |x|<1 \end{cases} $$
Pick any differentiable $\phi$ that vanishes at infinity, then
$$ \int\limits_{- \infty}^{\infty} y(x) \phi'(x) dx =2 \int\limits_1^{\infty}(x^2-1) \phi'(x) + \int\limits_{-1}^1 (1-x^2) \phi'(x) dx $$
We evaluate first integral. Notice that
$$ 2 \int_1^{\infty} x^2 \phi'(x) dx +2 \phi(1)= 2 x^2 \phi(x) \bigg|_1^{\infty} - 4 \int\limits_1^{\infty}\phi(x) x dx + 2 \phi(1) =- 4 \int\limits_1^{\infty} \phi(x) x dx$$
for the other integral we get
$$ \phi(1) - \phi(-1) - \int\limits_{-1}^1 x^2 \phi'(x) dx = 2 \int\limits_{-1}^1x \phi(x) dx$$
all in all, we obtain
$$ \int\limits_{- \infty}^{\infty} y \phi'(x) dx = 2 \int\limits_{-1}^1 x \phi(x) dx - 4 \int\limits_1^{\infty} x \phi(x) dx $$
RHS is of the form $\int\limits v(x) \phi(x) $ where
$$ v(x) = \begin{cases} - 4x, & x > 1 \\ 2x, & |x|<1 \end{cases} $$
So $v(x)$ is weak derivative. Is this correct?
Set $f(x) = |x^2-1|$ and take $\phi \in C_c^\infty(\mathbb{R})$. Then $$ -\int_{-\infty}^{\infty} D_\text{weak}f(x) \, \phi(x) \, dx = \int_{-\infty}^{\infty} f(x) \, \phi'(x) \, dx \\ = \int_{-\infty}^{-1} (x^2-1) \, \phi'(x) \, dx + \int_{-1}^{1} (1-x^2) \, \phi'(x) \, dx + \int_{1}^{\infty} (x^2-1) \, \phi'(x) \, dx \\ = \{ \text{ partial integration } \} \\ = \left( \left[ (x^2-1) \, \phi(x) \right]_{-\infty}^{-1} - \int_{-\infty}^{-1} 2x \, \phi(x) \, dx \right) + \left( \left[ (1-x^2) \, \phi(x) \right]_{-1}^{1} - \int_{-1}^{1} (-2x) \, \phi(x) \, dx \right) + \left( \left[ (x^2-1) \, \phi(x) \right]_{1}^{\infty} - \int_{1}^{\infty} 2x \, \phi(x) \, dx \right) \\ = \int_{-\infty}^{-1} (-2x) \, \phi(x) \, dx + \int_{-1}^{1} 2x \, \phi(x) \, dx + \int_{1}^{\infty} (-2x) \, \phi(x) \, dx \\ = \int_{-\infty}^{\infty} \left\{\begin{aligned}-2x & \text{ if } |x|>1 \\ 2x & \text{ if } |x| < 1 \end{aligned}\right\} \, \phi(x) \, dx. $$
Thus, $$ D_\text{weak}f(x) = \left\{\begin{aligned}2x & \text{ if } |x|>1 \\ -2x & \text{ if } |x| < 1 \end{aligned}\right\} $$