title: Regular expression to trip beginning and ending from certificate PEM string
body: <p>Certificate PEM files contain the beginning and end like:</p>
  
  <pre><code>-----BEGIN CERTIFICATE----- [Base64 of certificate] -----END CERTIFICATE
  </code></pre>
  
  <p>I need to extract just the <code>[Base64 of certificate]</code> part, i.e., strip off the <code>"-----BEGIN CERTIFICATE----- "</code> and <code>" -----END CERTIFICATE-----"</code> strings , and was wondering if this could be done with a regex, and if so what would that regex look like?</p>
  
  <p>I've tried:</p>
  
  <pre><code>-----BEGIN CERTIFICATE----- (.*) -----END CERTIFICATE-----
  </code></pre>
  
  <p>but, rather than giving me the Base64 of the cert, it's returning everything.</p>
  
  <p>Thanks,
  Jim</p>