Advertisement
Guest User

indus

a guest
Aug 6th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. class ArrayMaker
  2.     {
  3.         public string rawStr { get; set; }
  4.         public Dictionary<string,string> Dict;
  5.         private string pKey = @"\w+=";
  6.         private string pValue = @"=(.*?)(\s)";
  7.        
  8.         public ArrayMaker(string input)
  9.         {
  10.             rawStr = input;
  11.         }
  12.         public void FillDict()
  13.         {
  14.             Dict = new Dictionary<string,string>();
  15.             string sKey = "";
  16.             string sValue = "";
  17.             string[] splittedSrr = rawStr.Split(new Char[] {','});
  18.             foreach (string s in splittedSrr) {
  19.                
  20.                 Match key = Regex.Match(s, pKey);
  21.                 if (!key.Value.Equals("")) { sKey = key.Value.Substring(0, key.Value.Length-1); }
  22.                 Match value = Regex.Match(s, pValue);
  23.                 if (!value.Value.Equals("")) { sValue = key.Value.Substring(0, key.Value.Length - 1); }
  24.  
  25.                 Dict.Add(sKey,sValue);
  26.             }
  27.         }
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement