This is a follow-up to this question.
I have a big sum, with lots of terms of the form
Times[Complex[0, Rational[-1, 4]], Power[2, Rational[-1, 2]], Aurb, Bdrb, h]
Each term in the sum consists of five objects, 2 numbers, one h[i] and an object starting with A, e.g. Aurb and an object starting with B, as for example, Bdrb.
I want to transform every term such that I have only terms of the form
Times[ComplexNumber, RealNumber, h[i], KroneckerProduct[A..., B...]],
for the term above
Times[Complex[0, Rational[-1, 4]], Power[2, Rational[-1, 2]], h, KroneckerProduct[Aurb, Bdrb]]
The important thing is that always the
B... are put into the
KroneckerProduct. How can I tell the Mathematica to always replace my terms like this? Ideally, I want that Mathematica checks for all elements that are part of a given list, for example
MemberQ[All my objects starting with A, ...] and put it then at the correct spot in the replacement rule.