java - How to parse the string into map -


have string a=b&c=d&e=f, how parse map?

i use split

string text = "a=b&c=d&e=f"; map<string, string> map = new linkedhashmap<string, string>(); for(string keyvalue : text.split(" *& *")) {    string[] pairs = keyvalue.split(" *= *", 2);    map.put(pairs[0], pairs.length == 1 ? "" : pairs[1]); } 

edit allows padded spaces , value = or no value. e.g.

a = minus- & c=equals= & e==f 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -