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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -