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

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -