title: Need help creating a Regex that will match certain c# strings that contain json
body: <p>I have a bunch of Json style strings in C#, and I'm trying to take the raw string that's actually in the CS file and convert it to a string.format to help parameterize a web request.</p>
  
  <p>So far I have not been able to come up with something that works.</p>
  
  <p>I need a single regex that will match both of these strings:</p>
  
  <pre><code>    "{\"effectiveTimestamp\":null
  </code></pre>
  
  <p><code>\"foo\":1029231}");</code></p>
  
  <p>My regex looks like the following</p>
  
  <p><code>\s*\"?{?(.*?):(.*)(?:}\"\);)?</code></p>
  
  <p>I've tried different variations of greed and non greedy for the last 2 capture groups. </p>
  
  <p><code>\s*\"?{?(.*?):(.*)(?:}\"\);)*</code></p>
  
  <p><code>\s*\"?{?(.*?):(.*)(?:}\"\);)*?</code></p>
  
  <p><code>\s*\"?{?(.*?):(.*?)(?:}\"\);)*</code></p>
  
  <p><code>\s*\"?{?(.*?):(.*?)(?:}\"\);)*?</code></p>
  
  <p>As well as trying to match 0 or 1 times</p>
  
  <p><code>\s*\"?{?(.*?):(.*)(?:}\"\);)?</code></p>
  
  <p>But no matter what I do it either fails to grab the second group in the first string or the second string. I can't get it to grab the 2nd group correctly in both cases.</p>
  
  <p>Got the answer from Matt:</p>
  
  <p>This captures what I needed.</p>
  
  <p><code>([\w\\"]*):([\w\\"]+)</code></p>