title: Regex performance issue on a really big string
body: <p>Right now I am new to using regexes so I would really appreciate your help.</p>
  
  <p>I have a really large string (I am parsing an as3 file to json) and I need to locate for those trailing commas out there in the objects.. </p>
  
  <p>This is the regex I am using </p>
  
  <pre><code>public static string TrimTraillingCommas(string jsonCode)
  {
      var regex = new Regex(@"(.*?),\s*(\}|\])", (RegexOptions.Multiline));
  
      return regex.Replace(jsonCode, m =&gt; String.Format("{0} {1}", m.Groups[1].Value, m.Groups[2].Value));
  }
  </code></pre>
  
  <p>The problem with it is that it's really slow. Without using it in the string the time to complete the program is : <code>00:00:00.0289668</code> and with it :  <code>00:00:00.4096293</code></p>
  
  <p>Could someone suggest a improved regex or algorithm for faster replacing those trailing commas.</p>
  
  <p><a href="http://pastebin.com/xZqFbu4Q" rel="nofollow">Here is where i start from ( the string with the trailing commas )</a></p>
  
  <p><a href="http://pastebin.com/kTfzFc6g" rel="nofollow" title="this is the end string I desire">Here is the end string I need</a></p>