title: C# regex to extract multiple structure key value
body: <p>I found some regex to extract key-value style format</p>
  <p>but recent I encounter some format like below</p>
  <pre><code>&quot;Key1&quot;=123,&quot;Key2&quot;=&quot;abc&quot;,&quot;key3&quot;={&quot;subkey1&quot;=12,&quot;subkey2&quot;=&quot;cd&quot;},&quot;key4&quot;=456
  </code></pre>
  <p>this what I wish to output</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>match</th>
  <th>Key</th>
  <th>value</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>match0</td>
  <td>Key1</td>
  <td>123</td>
  </tr>
  <tr>
  <td>match1</td>
  <td>Key2</td>
  <td>&quot;abc&quot;</td>
  </tr>
  <tr>
  <td>match2</td>
  <td>key3</td>
  <td>{&quot;subkey1&quot;=12,&quot;subkey2&quot;=&quot;cd&quot;}</td>
  </tr>
  <tr>
  <td>match3</td>
  <td>key4</td>
  <td>456</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>how can I escape the &quot;,&quot; inside {}</p>
  <p>I tried</p>
  <pre><code>&quot;(?&lt;key&gt;\w+)&quot;=(?&lt;value&gt;{?&quot;?[^,]*&quot;?}?)
  </code></pre>
  <p>but
  the result is like</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>match</th>
  <th>Key</th>
  <th>value</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>match0</td>
  <td>Key1</td>
  <td>123</td>
  </tr>
  <tr>
  <td>match1</td>
  <td>Key2</td>
  <td>&quot;abc&quot;</td>
  </tr>
  <tr>
  <td>match2</td>
  <td>key3</td>
  <td>{&quot;subkey1&quot;=12</td>
  </tr>
  <tr>
  <td>match3</td>
  <td>subkey2</td>
  <td>&quot;cd&quot;}</td>
  </tr>
  <tr>
  <td>match4</td>
  <td>key4</td>
  <td>456</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>is there any help to escape only when &quot;,&quot; inside {}?</p>