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