c# - String parsing using RegEx -
i have string below.
x:= fmlvar("function1", "var1");
i parse above string , 2 arguments ("funtion1" , "var1"). fmlvar function accepts 2 strings arguments.
at present, using string manipulation function such indexof , substring process above string , strip out arguments.
is there better way doing this? possibly using regular expression.
any advice appreciated.
thanks
alan
try this:
var s = "x:= fmlvar(\"function1\", \"var1\");"; var match = new regex(@"fmlvar\(""(.+?)"", ""(.+?)""\);").match(s); var arg1 = match.groups[1]; var arg2 = match.groups[2];
Comments
Post a Comment