I'm converting some excel formulas to another system and need to do some fairly nifty search and replace magic. I presume Regex are the tools for the job in this case, but if anyone has any other ideas I'd like to hear them.
I'm working on getting these formulas into something resembling SQL syntax. I also have to deal with algebraic symbols so I might have the following:
9^2 will need to become POWER(9,2). (A + 3)^3 will need to become POWER((A+3),3).
Whats the best approach for this?
I'm using C# 3.5 if that makes a difference.
edit: An example of something I have to parse (the power symbol is near the end):
"((({VAL(9286)} / 1000) * {VAL(4648)}) + (({VAL(9609)} / 1000) + ({VAL(6480)} / 1000)) * {VAL(8574)}) / ({VAL(9286)} / 1000 + {VAL(9609)} / 1000 + {VAL(6480)} / 1000) * (({VAL(9286)} / 22.4)*34.38 + {VAL(9609)} + {VAL(6480)}) * ((1.075068 + 0.001*11.17019 * ((({VAL(9286)} / 1000) * {VAL(4648)}) + (({VAL(9609)} / 1000) + ({VAL(6480)} / 1000)) * {VAL(8574)}) / ({VAL(9286)} / 1000 + {VAL(9609)} / 1000 + {VAL(6480)} / 1000)+273.15)) + (100000*0.90755 / ((({VAL(9286)} / 1000) * {VAL(4648)}) + (({VAL(9609)} / 1000) + ({VAL(6480)} / 1000)) * {VAL(8574)}) / ({VAL(9286)} / 1000 + {VAL(9609)} / 1000 + {VAL(6480)} / 1000) + 273.15)^2))*4.1868/32)"