title: Get string between first and last occurrence of selected characters with C# in a performant way
body: <p>I have a string that can contain any characters, but I want the text between the first and last occurrence of characters.</p>
  <p>Example string:</p>
  <pre><code>&quot;x{1{hello}}y}z&quot;
  </code></pre>
  <p>I want the string between the first <code>{</code> and the last <code>}</code></p>
  <p>Expected result:</p>
  <pre><code>&quot;1{hello}}y&quot;
  </code></pre>