I have never dealt with regular expressions before, and I am facing a problem here. The user has to input a text like Var1(0,enum1,enum2), and I have to check the syntax on the following manner:-
1- make sure Var1 name matches the list of variables I have.. Just a string comparison
2- make sure the parameters are input in sequence.
3- dropping any parameter is allowed. and also no parameter at all is allowed
then I have to take the parameters to fill up some object
will regex do the trick for me, or I have to go for writing a parser !?
Thanks!
I wouldn’t do this with a regular expression, but here’s one that does what you want (I am using general regexp syntax – nothing C# specific).
Assuming that the variables are var1, var2, var_3, and the the options for paramater 1 are par1_1, par1_2 and the options for parameter 2 are par2_1, par2_2, par2_3, etc then the regular expression is:
Note that: