Let Expr
be an expression that can be practically any combination of variables. Now I can check whether this expression contains any subscripts or superscripts with help of
!FreeQ[Expr,Subscript]
!FreeQ[Expr,Superscript]
However, in a next step I would like to read out a list of all appearing sub- and superscripts explicitly without introducing more constraints on how the expression should look like specifically. Is there any function that does this? Or maybe one can implement it? Thanks for any suggestion!
Example:
Expr = (h*Superscript[u, g]*Superscript[Subscript[a, b, c], z])^Pi;
GetSubAndSuperscripts[Expr]
{g,z,b,c}
The point is, that it should not matter how exactly the expression is organized. The function should simply return all appearing Superscripts and Subscripts.
Cases
do? $\endgroup$Cases
is too specific. I will add an example to the question to make it more clear. $\endgroup$