title: Regular expression takes unsual amount of time?
body: <p>Here's the code I'm running :</p>
  
  <pre><code>Dim descriptionMatches As MatchCollection = Regex.Matches(pageJSON, "\[\[(([\w]+[\s]*)+)\]\], (([\w]+[\s]*)+)\\n")
  Console.WriteLine(descriptionMatches.Count)
  </code></pre>
  
  <p>Now, everything works fine until the last line. Looks like the MatchCollection.Count() method takes really long to execute, so long, I've run the program for more than 2 minutes...</p>
  
  <p>Here's some additional information.</p>
  
  <ul>
  <li><p>When I cut the regex pattern to just <code>"\[\[(([\w]+[\s]*)+)\]\]"</code> I get 35 matches and it's seemingly instantaneous.</p></li>
  <li><p>When I use a for loop to parse through the MatchCollection, if I use a loop in the form of for i=0 to matchcollection.count, the loop doesn't get executed (like the regex is still trying to analyse the input string. And if I use a for each (the difference is that the latest uses an iterator) I get to about the 15th match before it freezes. Weird isn't it?</p></li>
  <li><p>Here's the a link to the string I'm trying to match, as you will see, it's not the longest string ever : <a href="http://en.wikipedia.org/w/api.php?format=json&amp;action=query&amp;titles=SRS&amp;prop=revisions&amp;rvprop=content" rel="nofollow">Wikipedia API result for SRS</a></p></li>
  <li><p>In the probable case where my pattern is the problem and you want to suggest me a new pattern, what I'm trying to match looks like this : </p></li>
  </ul>
  
  <blockquote>
    <p>[[Name of item]], description of item\n</p>
  </blockquote>
  
  <p>I've used regular expressions a lot in the past and this has never happened to me. If someone knows what is the problem, could you please tell me what it is and how to fix it?</p>