\(=\dfrac{x^2\left(x-1\right)+2x-x-1+x^2-1}{\left(x-1\right)\left(x+1\right)}\)
\(=\dfrac{x^3-x^2+x+x^2-2}{\left(x-1\right)\left(x+1\right)}\)
\(=\dfrac{x^3+x-2}{\left(x-1\right)\left(x+1\right)}\)
\(=\dfrac{x^3-x+2x-2}{\left(x-1\right)\left(x+1\right)}=\dfrac{x\left(x-1\right)\left(x+1\right)+2\left(x-1\right)}{\left(x-1\right)\cdot\left(x+1\right)}\)
\(=\dfrac{x^2+x+2}{x+1}\)