Message Boards Message Boards

0
|
7828 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

ToExpression and strings like "5--1", "5 is not a variable with a value"?

POSTED BY: Christopher Fox
2 Replies
POSTED BY: Sander Huisman
Posted 8 years ago

You can get the effect you want by using StringReplace to insert a space between the two minus signs as,

s = "5--1";
ToExpression[StringReplace[s, "--" -> "- -"]]
POSTED BY: Louis Godwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract