This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / Built-in Functions / Input and Output / Formatting Functions /

ToExpression

FilledSmallSquare ToExpression[input] gives the expression obtained by interpreting strings or boxes as Mathematica input.

FilledSmallSquare ToExpression[input, form] uses interpretation rules corresponding to the specified form.

FilledSmallSquare ToExpression[input, form, h] wraps the head h around the expression produced before evaluating it.

FilledSmallSquare Example: ToExpression["1 + 1"] LongRightArrow.

FilledSmallSquare form can be InputForm, StandardForm, TraditionalForm or MathMLForm.

FilledSmallSquare ToExpression["string"] uses InputForm interpretation rules.

FilledSmallSquare ToExpression[boxes] uses StandardForm interpretation rules.

FilledSmallSquare ToExpression prints a message and returns $Failed if it finds a syntax error. ToExpression does not call $SyntaxHandler.

FilledSmallSquare The input given in ToExpression can correspond to multiple Mathematica expressions. ToExpression processes each one in turn, just like Get.

FilledSmallSquare ToExpression[input, form, Hold] can be used to convert input to an expression, but with the expression wrapped in Hold to prevent evaluation.

FilledSmallSquare ToExpression uses any relevant definitions given for MakeExpression.

FilledSmallSquare See Section 2.9.4.

FilledSmallSquare See also: Symbol, MakeExpression, ToString, ToBoxes, SyntaxQ, SyntaxLength, Read, Get.

FilledSmallSquare New in Version 1; modified in 4.1.

Further Examples