title: Extract all strings between two strings
body: <p>I'm trying to develop a method that will match all strings between two strings:</p>
  
  <p>I've tried this but it returns only the first match:</p>
  
  <pre><code>string ExtractString(string s, string start,string end)
          {
              // You should check for errors in real-world code, omitted for brevity
  
              int startIndex = s.IndexOf(start) + start.Length;
              int endIndex = s.IndexOf(end, startIndex);
              return s.Substring(startIndex, endIndex - startIndex);
          }
  </code></pre>
  
  <p>Let's suppose we have this string  </p>
  
  <pre><code>String Text = "A1FIRSTSTRINGA2A1SECONDSTRINGA2akslakhflkshdflhksdfA1THIRDSTRINGA2"
  </code></pre>
  
  <p>I would like a c# function doing the following :</p>
  
  <pre><code>public List&lt;string&gt; ExtractFromString(String Text,String Start, String End)
  {
      List&lt;string&gt; Matched = new List&lt;string&gt;();
      .
      .
      .
      return Matched; 
  }
  // Example of use 
  
  ExtractFromString("A1FIRSTSTRINGA2A1SECONDSTRINGA2akslakhflkshdflhksdfA1THIRDSTRINGA2","A1","A2")
  
      // Will return :
      // FIRSTSTRING
      // SECONDSTRING
      // THIRDSTRING
  </code></pre>
  
  <p>Thank you for your help !</p>