title: String to dictionary using regex (want to optimize)
body: <p>I have string on the format <code>"$0Option one$1$Option two$2$Option three"</code> (etc) that I want to convert into a dictionary where each number corresponds to an option. I currently have a working solution for this problem, but since this method is called for every entry I'm importing (few thousand) I want it to be as optimized as possible.</p>
  
  <pre><code>public Dictionary&lt;string, int&gt; GetSelValsDictBySelValsString(string selectableValuesString)
  {
      // Get all numbers in the string. 
      var correspondingNumbersArray = Regex.Split(selectableValuesString, @"[^\d]+").Where(x =&gt; (!String.IsNullOrWhiteSpace(x))).ToArray();
  
      List&lt;int&gt; correspondingNumbers = new List&lt;int&gt;();
  
      int number;
      foreach (string s in correspondingNumbersArray)
      {
          Int32.TryParse(s, out number);
          correspondingNumbers.Add(number);
      }
  
      selectableValuesString = selectableValuesString.Replace("$", "");
  
      var selectableStringValuesArray = Regex.Split(selectableValuesString, @"[\d]+").Where(x =&gt; (!String.IsNullOrWhiteSpace(x))).ToArray();
  
      var selectableValues = new Dictionary&lt;string, int&gt;();
  
      for (int i = 0; i &lt; selectableStringValuesArray.Count(); i++)
      {
          selectableValues.Add(selectableStringValuesArray.ElementAt(i), correspondingNumbers.ElementAt(i));
      }
  
      return selectableValues;
  }
  </code></pre>