I need help and guidance for a mechanism of detecting, replacing with numbers and evaluating math formulas in a string. The fomula is enclosed in a pre-defined starr and end symbol.
Example:
A train starts at \[a+b*c\] m/s . it acceelates at \[a/b\] m/s2
Now we have values of a & b , we want to replace the values in the string and evaluate expression.
Like so
if a=1, b=2,c=3
A train starts at 7 m/s . it acceelates at 0.5 m/s2
I'm kindly asking for assist with a possible example in C# of how can this be achieved?
Any help is appreciated. (I'm almost alien to regex)
EDIT: Apologies I forgot to mention, the variables / their vals, their symbol are all unknown. We need to evaluate this dynamically. String are entered by user and below he/she tells the variables used and their value range.