5ab^2+3ab-7-8ab+10-3a^2b
Is the following what you are looking for?
Collect the ab terms and the constant terms:
5ab2 -5ab -3a2b+3
ab is common to the first three terms above, so
ab(5b - 5 - 3a) + 3
ab(5(b-1) - 3a) + 3
.