So going back, you need to solve:
[ A(1-x+x^2)+B(x+2) ] / [ (x+2)(1-x+x^2) ] = (3x-1) / [ (x+2)(1-x+x^2) ]
As I said, the denominators are already equal, so you need to make the numerators equal.
That means you need to make this:
A(1-x+x^2)+B(x+2)
equal to (3x-1). Expand this - you already know that the second part becomes B.x+2B - and have a look.Then think - what can you set A and B to be to make it equal to 3x-1?
What if you set A to be x?
What if you set B to be 2?
What if you set A to be -3?
What if you set B to be 2x?
Try those, try more, see if you can work out how you can get 3x-1. Here's a hint: when you expand you'll get one of the terms as Ax^2. How can you get that to cancel out?
Try things. Tell me what you see, tell me what you get.