0
$\begingroup$

Considering a fraction:

val = "F \!\(\*FractionBox[\(1\), \(1\)]\)";

I extract the part of interest:

>>    res = StringTake[val, {5, StringLength@val - 1}]
<<    "\!\(\*FractionBox[\(1\), \(1\)]\)"

Now want to check if res is greater that 0 or no. How can I parse res to a number?

Thanks!

$\endgroup$
  • 4
    $\begingroup$ Times @@ ToExpression@StringCases[res, NumberString] > 0, but I have to wonder why you're doing such machinations with this and your prior question re: numbers in strings... $\endgroup$ – ciao Jul 17 '15 at 8:46
  • $\begingroup$ @ciao, I have two parts: representation and validation. $\endgroup$ – SuTron Jul 17 '15 at 9:06
  • 1
    $\begingroup$ I think Divide @@ ToExpression@StringCases[res, NumberString] > 0 instead of Times .... $\endgroup$ – SuTron Jul 17 '15 at 9:09
  • 5
    $\begingroup$ I think since only sign matters Times also works? $\endgroup$ – Mr.Wizard Jul 17 '15 at 9:18
  • 1
    $\begingroup$ @Mr.Wizard Is this easy to find in documentation or worth an answer? $\endgroup$ – Kuba Dec 15 '15 at 21:43

Your Answer

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

Browse other questions tagged or ask your own question.