You should not assume that the input will always in the 3 parameter form. Rather, take a generic input, parse on it based on use cases.
In your case, it boils down to two specific use cases AFTER you accept the input:
- Operators that operate on single operand - unary operator
- Operators that operate on double operand - binary operator
For each case, you can define a list of operators allowed. E.g. '!' will be in case 1 list, while '*' will be in case '2'
scan through the string, look for the operator position. [^0-9] (represents a pattern which other than numbers). Or simply you can do a trivial check for the operator (by creating your own custom method)
Once you have figured out this, validate your string (optional) - e.g. makes no sense to have two operands for a unary operator.
Having done this, it is fairly easy to parse now the required operands by splitting out the string based on the operator. Computation is fairly trivial then.
Hope this helps.