Extracting parts of a string c#
<p>In C# what would be the best way of splitting this sort of string?</p>

<p><code>%%x%%a,b,c,d</code></p>

<p>So that I end up with the value between the %% AND another variable containing everything right of the second %%
i.e. <code>var x = "x"; var y = "a,b,c,d"</code></p>

<p>Where <code>a,b,c..</code> could be an infinite comma seperated list. I need to extract the list and the value between the two double-percentage signs.
(To combat the infinite part, I thought perhaps seperating the string out to: <code>%%x%%</code> and <code>a,b,c,d</code>. At this point I can just use something like this to get X.</p>

<pre><code>var tag = "%%";
      var startTag = tag;
      int startIndex = s.IndexOf(startTag) + startTag.Length;
      int endIndex = s.IndexOf(tag, startIndex);
      return s.Substring(startIndex, endIndex - startIndex);
</code></pre>

<p>Would the best approach be to use regex or use lots of <code>indexOf</code> and <code>substring</code> to do the extracting based on te static <code>%%</code> characters?</p>
