I need a string like the following:
"2+2 \"Hello world\" 3+3"
to be evaluate like
2+2 "Hello world" 3+3
ToExpression evaluates that string as
2+2; "Hello world"; 3+3
that is that it prints only the last line.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.Sign up to join this community
If I understand your question correctly, the following code
str = "2+2 \"Hello world\" 3+3"; ToExpression[str, InputForm, Print /@ List[##] &];
does what you want. Alternatively, you can use
ToExpression[str, InputForm, List]
and decide what to do with the list later. The documentation for
ToExpression[input, form, h]
wraps the head h around the expression produced before evaluating it.