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