It is similar on dividing whole numbers.
let y = x² + 4x - 12 / x - 2
Divide the first term of the dividend to that of the first term of the divisor.
x² / x = x
The quotient will be the first term of your answer.
Multiply first the quotient by the terms of the divisor.
x(x) = x²
x(-2) = -2x
And then put it below the terms of the dividend.
Subtract the terms of the divisor by the product.
x² - x² = 0
4x - (-2x) = 6x
Bring down one term left next to the difference.
6x - 12
Then go, repeat to step 1.
y = x + 6
Now, can you get it? :)