As all of the comments to your question indicate, you need some kind of tokenizer, expression parser, and expression evaluator.
The tokenizer splits the source string into separate tokens, like numbers and operators.
The expression parser scans and syntactically parses the sequence of tokens, recognizing expressions and building some kind of parse tree (i.e., an abstract expression tree).
The expression evaluator then walks the nodes of the resulting expression tree, evaluating the binary and unary subexpressions. The result is the evaluation of the top-most node in the tree.
This is all quite a complex set of things to do, so (like the other comments state), you should try to find a library that someone has already written to do all this for you.