Collect with symbolic exponents

I need to collect a polynomial in a variable r. The exponents of r are possbily symbolic.
For example, the expression

Collect[r^(2 a) (1 + r^2) + (1 + a) r^2, r]

gives

r^(2 a) + r^2 (1 + a + r^(2 a))

while what I would like to have is

r^(2 a) + r^2 (1 + a) + r^(2+2 a)

Of course my expression is much more complicated, but this gives the idea of what happens.

=================

  

 

What about Expand insted of Collect?
– Fred Simons
Sep 22 at 9:06

  

 

@FredSimons I want all the terms that are multiplied by the same power of r to stay together. Expand would not work in this case. I will change the example to make it clearer
– bnado
Sep 22 at 9:10

=================

1 Answer
1

=================

Your example with some extra terms:

exp=r^(2 a)+r^2 (1+a+r^(2 a)) + r + a r;

Collect accepts patterns, so you can collect with respect to powers of r:

Collect[exp, r^_]
(* (1+a) r+(1+a) r^2+r^(2 a)+r^(2+2 a) *)