# ReplaceAll rules for Power function

I have the following function:

eW = fL11(u1L^r + u2L^r) + fM11(u1M^r+ u2M^r) + fH11(u1H^r + u2H^r)


The full form of eW is then:

Plus[Times[Rational[1,3],Plus[Power[u1H,r],Power[u2H,r]]],Times[Rational[1,3],Plus[Power[u1L,r],Power[u2L,r]]],Times[Rational[1,3],Plus[Power[u1M,r],Power[u2M,r]]]]


I want to replace the power r to the specific value 1.5 for all variables u1_

I have tried eW /. r-> 1 , but it does not work.

Can anyone suggest me how to write ReplaceAll correctly?

• Do you want to replace only the r's in the exponent of u1* variables, or do you want every r replaced? – Robert Jacobson Dec 8 '18 at 4:43

eW /. Power[a_?(StringMatchQ["u1*"]@*SymbolName), r] :> a^(3/2)


fH11 (u1H^(3/2) + u2H^r) + fL11 (u1L^(3/2) + u2L^r) + fM11 (u1M^(3/2) + u2M^r)

Also

eW /. Power[a_ /; StringMatchQ["u1*"]@SymbolName[a], r] :> a^(3/2)


fH11 (u1H^(3/2) + u2H^r) + fL11 (u1L^(3/2) + u2L^r) + fM11 (u1M^(3/2) + u2M^r)

and

eW /. Power[a : (u1L | u1M | u1H), r] :> a^(3/2)


fH11 (u1H^(3/2) + u2H^r) + fL11 (u1L^(3/2) + u2L^r) + fM11 (u1M^(3/2) + u2M^r)