How to execute a String code in the form of StandardForm?
I want to get execution results for strings of various forms. For this, I used ToExpression.
case1 = ToExpression["(1/2)^3"]
case2 = ToExpression["\!\(\*SuperscriptBox[FractionBox[\(1\), \(2\)], \(3\)]\)"]
case3 = ToExpression["(\!\(\*FractionBox[\(1\), \(2\)]\)\!\(\*SuperscriptBox[\()\), \\(3\)]\)"]
As a result of execution, Case 3 did not get the result I wanted. How can I solve it?
Here's a GIF showing how 3rd string is created:
As we can see, once the pair of "
is added, the size of ()
becomes a bit weird.
()
isn't in aRowBox
in 3rd case. If the string is obtained with e.g.ToString[(1/2)^3 // Unevaluated, StandardForm]
,ToExpression
will handle it properly, though. $\endgroup$"
. Perhaps this gif could be included in the question/bug report. $\endgroup$