\(x^2+4x-y^2+4\)
\(=\left(x^2+4x+4\right)-y^2\)
\(=\left(x+2\right)^2-y^2\)
\(=\left(x+2+y\right)\left(x+2-y\right)\)
\(3x^2-4x+1=3x^2-3x-x+1\)
\(=3x\left(x-1\right)-\left(x-1\right)\)
\(=\left(3x-1\right)\left(x-1\right)\)
\(x^2y+xy+\left(x^2-1\right)\)
\(=xy\left(x+1\right)+\left(x-1\right)\left(x+1\right)\)
\(=\left(x+1\right)\left(xy+x-1\right)\)