I am creating a program that enables the user to create some sort of script. I compile his script at runtime and then executed. I am doing something like: https://stackoverflow.com/a/4181855/637142
Anyways to make the long story short basically I have to replace all the variables that start with $. for something that will make the script compile. If the user has the following line:
var x = ($MyArray[ 4 ].Size) + 3;
what regex will enable me to select $MyArray[ 4 ].Size
?
If the user where to write:
var x = $SomeVar;
In that case it would be easy to find SomeVar
. I am having trouble finding variables that start with $
Edit
I think I am close on finding the solution. Right now I am replacing the $ with the word Foo.
in other words I replced the line:
var x = ($MyArray[ 4 ].Size) + 3;
for
dynamic Foo; // then
var x = (Foo.MyArray[ 4 ].Size) + 3;
Now it compiles but I would still need to find Foo.MyArray[ 4 ].Size
Edit 2
I am not trying to create a compiler I just need to replace some variables (the ones that start with $) nothing more ;)