'Matching Math expression with Regex

Valid math expressions:

a * b + c

-a * b / 1.50

a + b * 4.6 - k

And these are invalid math expressions:

--a *+ b @ 1.5.0 // two consecutive signs, two consecutive operators, invalid operator, invalid number

I am not looking for valid parentheses, only the combination of float/double digits and variables.

I tried to come up something like this - but its not working ^[-+]?([-+/]\d+(.\d+)? || [-+/][a-zA-Z])*

Any help would be appreciated. TIA



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source