Oct-09-2019, 05:58 AM
(This post was last modified: Oct-09-2019, 05:58 AM by Gribouillis.)
If you could cut the expression on the character that is not valid in an arithmetic expression, you could parse the different pieces with the ast module, provided the arithmetic expressions follow python's syntax. Alternatively, you could replace the invalid character by an operator with low precedence such as 'or' and parse directly the whole expression with the ast module, provided that none of the arithmetic expressions uses the 'or' operator.