Converting an old program into an ASP.NET c# site.
I have a table full of functions and a table full of variables with their corresponding values. I’ve written a function to evaluate the answers but need to format the formulas in order to pass the variable in.
For example:
V(totalValue) * V(CoFriction(s)) ==> V("totalValue") * V("CoFriction(s)")
How can I replace the V(<variable>) to V("<variable>"). Nested parenthesis are possible!
I’ve tried regexp like – V\([^\(\)]+\) only to fail on the nested paren.
You can achive it in .net using a balancing group:
The regex works exactly for the posted scenarios – it will fail miserably if the input isn’t valid, so you assume it is (specifically, when you have extra closing parentheses).