How to factorize $a^2-b^2-a+b+(a+b-1)^2$? The answer is $(a+b-1)(2a-1)$ but I have no idea how to get this answer.

Expand it and treat it as a quadratic expression in $a.$ That is if $C\ne 0$ then $Ca^2+Da+E=\;[a-(D- F)/2C]\;[a-(D+F)/2C)]\;$ where $F=\sqrt {D^2-4CE}.$ 
In this Q, we get $D^2-4CE=4b^2-4b+1=(2b-1)^2$ so it will simplify.
That is $$a^2-b^2-a+b+(a+b-1)^2=$$ $$= a^2-b^2-a+b +(a^2+2ab+b^2)-2(a+b)+1=$$ $$=2a^2+2ab -3a+b-1=$$ $$=2a^2+a(2b-3)+(b-1).$$ Let $C=2, D=2b-3,$ and $E=b-1.$
