"string to math expression"

how would you go about following the rules of math with sth like this:

5*7-3/8+2

(so that it correctly calculates 3/8 before 8+2)