title: Return part of string with comment markers
body: <p>I am looking for the most efficient way to get a portion of the string and using a HTML comment as the start/end points.</p>
  
  <p>So for example I want to use </p>
  
  <pre><code>&lt;!-- START: Variable --&gt;
  
  stuff goes here
  
  &lt;!-- END: Variable --&gt;
  </code></pre>
  
  <p>The string should just be the stuff in between the comments. I've made a helper but not really great with .net. </p>
  
  <pre><code>@helper readPattern(string filepath, string patternSection = null) {
  
      TextReader tr = new StreamReader(filepath);
      string SplitBy = "&lt;!-- START: "+patternSection+" --&gt;";
  
      string fullLog = tr.ReadToEnd();
  
      fullLog.Trim().StartsWith("&lt;!-- " + patternSection+ " --&gt;");
  
      //string[] sections = fullLog.Split(new string[] { SplitBy }, StringSplitOptions.RemoveEmptyEntries);
  
       &lt;div class="@patternSection"&gt;@fullLog&lt;/div&gt;
  }
  </code></pre>
  
  <p>I don't need to split it, I just need to output or trim it from the comments I pass through this helper.</p>