Don't use foreach over MatchCollection, use for. UPDATED
UPDATE. Apparently they both call GetMatch(). So my advice isn't correct. Thanks 'Reflector' for the comment. What surprises me though is that first my routine (checked with Ants profiler) was slow because of the foreach, and now it's not.
Simple performance tip. Consider this code:
MatchCollection matches = myRegExp.Matches(someString);
foreach(Match m in matches)
{
// your code which uses the match
This will perform awful. The reason is that the enumerator in MatchCollection executes the regexp again. This is, I guess, because you then can enumerate over the matchcollection without calling Matches. Instead do:
MatchCollection matches = myRegExp.Matches(someString); for(int i=0;i<matches.Count;i++) { Match m = matches[i]; // your code which uses the match