# Matching expressions with variable index ranges

+1 vote

I am trying to write a substitution that does essentially the following:

\gamma_{a}_{\alpha \beta} \gamma_{b}^{\beta \gamma} ->  X_{a b}_{\alpha}^{\gamma}

but with $a$ and $b$ allowed to be a range of vector indices, e.g. I want to also encompass

\gamma_{a1 a2 a3}_{\alpha \beta} \gamma_{b}^{\beta \gamma} ->  X_{a1 a2 a3 b}_{\alpha}^{\gamma}

and so on. I can of course define this for all possible collective indices a_i and b_i, or introduce some intermediate kluge, but I suspect there ought to be a compact, elegant way of doing this. My initial instinct was to try

\gamma_{A??}_{\alpha \beta} \gamma_{B??}^{\beta \gamma} ->  X_{A?? B??}_{\alpha}^{\gamma}

but this doesn't seem to work. Any ideas of a simple solution?

There should be a compact, elegant way of doing this, but there isn't. There are some bits of code in various places referring to 'range wildcards', but I never had time to complete that.

OK. I kludged it up! :-D