Are you looking for a function to do this? I'm not exactly sure what this meant to do for a general case, but for your specific case I might write some code like this:
eqn = Expand[(x + 1/x)^3];
This gives us the expanded form you mentioned. Next we need to specify what powers of x we want to treat separately from the rest and pull them out of the equation:
pattern = _ x | _ Power[x, -1];
{matches, extra} = {Cases[eqn, pattern], Cases[eqn, Except@pattern]}
The tool we want to use to factor the number three out of the section that matches our pattern is FactorTerms. So
FactorTerms[Plus @@ matches] Gives
3 (1/x + x):
targetFormat = Plus @@ extra + FactorTerms[Plus @@ matches]
This gives us the form you wanted for the equation and then we can subsitute that case of
x+ 1/x for
1:
targetFormat /. (1/x + x) -> 1