1
$\begingroup$

Considering we have:

in = "F 18/10"

How can I make this to be:

enter image description here

Thanks!

$\endgroup$
  • 1
    $\begingroup$ You want the output to be a String too, correct? $\endgroup$ – Mr.Wizard Jul 16 '15 at 9:54
2
$\begingroup$

Please try:

StringReplace[in, 
 d1 : DigitCharacter .. ~~ "/" ~~ d2 : DigitCharacter .. :> 
  "\!\(\*FractionBox[\(" ~~ d1 ~~ "\), \(" ~~ d2 ~~ "\)]\)"]
$\endgroup$
  • $\begingroup$ When trying to edit the output I see an error: INTERNAL SELF-TEST ERROR: MathEditCells2|c|1411 Click here to find out if this problem is known, and to help improve the Wolfram System by reporting it to Wolfram Research. $\endgroup$ – SuTron Jul 16 '15 at 12:21
  • 1
    $\begingroup$ @SuTron Unfortunately that's a bug in the Front End. If you manually create the same string in an Input cell, evaluate it, and try to edit the output I think you will get the same error. :-( $\endgroup$ – Mr.Wizard Jul 16 '15 at 12:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.