Use long division, as applied to algebraic factors. One proceeds by dividing leading terms into each other and then subtracting off what's left.
Divide #6x+2# into #12x^3-38x^2-26x-4#.
First step: #6x# goes into #12x^3# a factor of #2x^2#. So the first term in the answer is #2x^2# and we subtract #(2x^2)(6x+2)# off from the larger expression to get our remainder:
#(12x^3-38x^2-26x-4)-2x^2(6x+2)=(12x^3-38x^2-26x-4)-(12x^3+4x^2)=#
#-42x^2-26x-4#, the remainder of the larger expression.
Second step: Repeat the process with the remainder.
#6x# goes into #-42x^2# a factor of #-7x#. Thus the second term of our answer is #-7x# and we subtract #(-7x)(6x+2)# off from the larger expression to get our remainder:
#(-42x^2-26x-4)-(-7x)(6x+2)=(-42x^2-26x-4)+(42x^2+14x)=#
#-12x-4#, the remainder.
Third step: Repeat again.
#6x# goes into #-12x# a factor of #-2#. Thus the third term of our answer is #-2#, and we subtract #-2(6x+2)# from the larger expression to get the remainder:
#(-12x-4)-(-2)(6x+2)=(-12x-4)+(12x+4)=0#.
At this point our remainder is zero, which means that the smaller expression divides exactly into the larger. If it had not been zero, there would have been an extra fractional term with #6x+2# as the denominator and the remainder as the numerator.
Collecting together the terms we've calculated, the answer is:
#2x^2-7x-2#