c# - Extract variables from querystring -


i need parse following string

/mydata.csv(membercount.sum,production.sum[salesperson="james almond","area="europe "area 1" (germany)",area="north america",area="north america [level a]"]) 

the first part easy, clause within brackets ([]) giving me bit of headache since can contain double quotes example shows. (note content within brackets can change dynamically)

i expect following output when parsing last part of string :

salesperson james almond area europe "area 1" (germany) area north america area north america [level a]

i've been working regex can't seem right. hoping have magic!

you may give try balancing group definitions:

string pattern = @"^[^\[\]]*" +                 @"(" +                 @"((?'open'\[)[^\[\]]*)+" +                 @"((?'close-open'\])[^\[\]]*)+" +                 @")*" +                 @"(?(open)(?!))$";  var results =     regex.match(input, pattern)     .groups["close"].value     .split(new char[] { '=', ',' }); 

this outputs:

salesperson "james almond" area "europe "area 1" (germany)" area "north america" area "north america [level a]" 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -