How can i remove all "Defer[...]" from the following expression

 "Table[Times[Rational[-1, 12], Kx, Power[Lc, -1], Power[lp, -1], \
\\[Gamma], \\[Theta], Plus[Times[3, Plus[Times[-1, ax], bx], Plus[ax, \
bx], Defer[Part[n0, k]], Defer[Part[n0, l]]], Times[-3, Power[bx, 2], \
Defer[Part[delta, k, l]]], Times[Plus[Times[Power[bx, 2], Plus[i1, \
Times[-1, i4]]], Times[Power[ax, 2], i4]], Defer[Part[INVcx, k, \
l]]]], Plus[Times[Power[bx, 2], Plus[i1, Times[-1, i4]]], \
Times[Power[ax, 2], i4], Times[3, Lc, Plus[Times[2, Lc], Times[-3, \
Rbar]], Power[Det[F], Rational[2, 3]]]], Power[Plus[Times[Power[bx, \
2], Plus[i1, Times[-1, i4]]], Times[Power[ax, 2], i4], Times[4, Lc, \
Plus[Lc, Times[-2, Rbar]], Power[Det[F], Rational[2, 3]]]], -1], \
Power[Det[F], Rational[-2, 3]]],{k,3},{l,3}]"
  • 2
    $\begingroup$ You want to do this to a string? Why not an expression? $\endgroup$ – John Doty May 23 at 14:29
  • 1
    $\begingroup$ StringReplace[yourstring, "Defer[" ~~ Shortest[s__] ~~ "]" :> s], but @JohnDoty has a good point; it would be easier to do to an expression. $\endgroup$ – MarcoB May 23 at 14:33
  • 1
    $\begingroup$ It also seems that your string, treated as an expression, produces a 3x3 matrix with each element the same. I suspect there's a deeper underlying question from some other misunderstanding. $\endgroup$ – evanb May 23 at 14:39
  • 4
    $\begingroup$ This seems like it may be an XY problem. Are you certain it isn't? meta.stackexchange.com/questions/66377/what-is-the-xy-problem $\endgroup$ – Szabolcs May 23 at 15:13
  • 3
    $\begingroup$ I can't help but wonder: Why do you have a string in the first place? Why are you using Defer (it's misused extremely often)? $\endgroup$ – Szabolcs May 23 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.