title: C# extract text file block
body: <p>I need to extract Public key block from a file. The file looks like this:</p>
  
  <pre><code>..  some more data here ..
  -----BEGIN PGP PUBLIC KEY BLOCK-----
  
  Version: GnuPG v2.0.17 (MingW32)
  
  Stmjb2vAyoFAt5EbfNLEPCrwIDt7gB6cS2kldF7nechuNoyEzevJQMfQ8uJChR9g
  h/eUqqzE/cqCLHEruLMR38NCVYTEuCvTjOCtAnU9BCyX1Ir11aDUe0A4drcNISrv
  pEYjbNh4pb5sZbxKfMrx7PPUOsLH/vpMZFy/ABEBAAG0JEVsa2FydF90ZXN0XzIw
  MTEgPHN1cHBvcnRAZWxrYXJ0LnBsPokBOAQTAQIAIgUCTjaYUQIbAwYLCQgHAwIG
  ...
  -----END PGP PUBLIC KEY BLOCK-----
  .. some more data here ..
  </code></pre>
  
  <p>Before and afther that key block there is more info.
  Heres what i tried:</p>
  
  <pre><code>    static bool GetPublicKey(Stream keyI)
      {
          StreamReader reader = new StreamReader(keyI);
          string key = reader.ReadToEnd();
          Regex r = new Regex("(-----BEGIN PGP PUBLIC KEY BLOCK-----\\r\\n(.*?)-----END PGP PUBLIC KEY BLOCK-----\\r\\n)");
          Match m = r.Match(key);
          if (m.Success)
              return true;
      }
  </code></pre>
  
  <p>But i couldnt get it working..</p>
  
  <p>How could i do this with using regex?</p>