How can I take the string foo[]=1&foo[]=5&foo[]=2 and return a collection with the values 1,5,2 in that order. I am looking for an answer using
foo[]=1&foo[]=5&foo[]=2
1,5,2
I'd use this particular pattern:
string re = @"foo\[\]=(?\d+)";
So something like (not tested):
Regex reValues = new Regex(re,RegexOptions.Compiled); List values = new List(); foreach (Match m in reValues.Matches(...putInputStringHere...) { values.Add((int) m.Groups("value").Value); }