0

I have string as below.

X:= FMLVAR("Function1", "Var1");

I would like parse the above string and get the 2 arguments ("Funtion1" and "Var1"). FMLVAR is function which accepts 2 strings as arguments.

At present, I am using string manipulation function such as IndexOf and substring to process the above string and strip out those arguments.

Is there any better way doing this? Possibly using regular expression.

Any advice is much appreciated.

Thanks

Alan

4

1 回答 1

1

尝试这样的事情:

var s = "X:= FMLVAR(\"Function1\", \"Var1\");";

var match = new Regex(@"FMLVAR\(""(.+?)"", ""(.+?)""\);").Match(s);

var arg1 = match.Groups[1];
var arg2 = match.Groups[2];
于 2013-05-09T04:43:40.293 回答