I have strings like following:
"[Current.Age] - 10"
"[Current.Height] + 50"
"[Current.Age] + 10 - [Current.Height] - 50"
And I'd like to replace [Current.Something]
with the numerical value of the current selected object, for example a selected object may have the following state:
var student = new Student();
student.Age = 20;
student.Height = 180;
So, the strings should end up like:
"20 - 10" * or better * "10"
"180 + 50" * or better * "230"
"20 + 10 - 180 - 50" * or better * "-200"
I think I should use regular expressions for this. Any ideas as to how I can accomplish this?
Edit: What I need is pretty much something that can take [Current.Something]
s and replace them with relevant values. I know I can do it with simple string operations but I just wonder if there's a short way to do this.