I am trying to extract arguments from a call function of type string, for example:
GetStatus("Param1", "Param2", "ParamWith\"Quotations\"")
I am useless for regular expressions, but is it possible to match these parameter values in this way, including escaped quotes?
i.e. Param1, Param2, ParamWith "Quotes"
Even better, is there a way to extract the function name and only arguments if parentheses and arguments are present?
I use C # if that matters.
You can split and crop (to get the function name.
: ?. . LB , , .
, , , . , , , . , , Unix- (.. -options " " ), Regex:
Regex reg = new Regex("\".*?\"")
. "," . , , , , .
, "GetStatus (Param1, Param2, ParamsWith \" Quotations\ ")" , , ", " ".
String.split '(', , ',',
EDIT: , , . :
, ,
string fxn = @"GetStatus(""Param1"", ""Param2"", ""ParamWith\""Quotations\"""")"; var result = Regex.Matches(fxn, @"\""(?<GRP>[\w \\\""]+)\""|(?<GRP>\w+[ ]*)") .Cast<Match>() .Select(m => m.Groups["GRP"].Value) .ToArray();