title: Regex extract encoding type from given strings
body: <p>following a <a href="https://stackoverflow.com/q/17578724/1578604">recent thread</a> in stackoverflow, I'm posting a new question:
  I have several strings from which I want to extract the encoding type.
  I'm willing to do it using regex:</p>
  
  <p>Examples:</p>
  
  <pre><code>utf-8 quoted printable
  string str = "=?utf-8?Q?=48=69=67=68=2d=45=6e=64=2d=44=65=73=69=67=6e=65=72=2d=57=61=74=63=68=2d=52=65=70=6c=69=63=61=73=2d=53=61=76=65=2d=54=48=4f=55=53=41=4e=44=53=2d=32=30=31=32=2d=4d=6f=64=65=6c=73?=";
  
  utf-8 Base 64
  string fld4 = "=?utf-8?B?VmFsw6lyaWUgTWVqc25lcm93c2tp?= &lt;Valerie.renamed@company.com&gt;";
  
  Windows 1258 Base 64
   string msg2= "=?windows-1258?B?UkU6IFRyIDogUGxhbiBkZSBjb250aW51aXTpIGQnYWN0aXZpdOkgZGVz?= =?windows-1258?B?IHNlcnZldXJzIFdlYiBHb1ZveWFnZXN=?=";
  
  iso-8859-1 Quoted printable 
  string fld2 = "=?iso-8859-1?Q?Fr=E9d=E9ric_Germain?= &lt;Frederic.Germain@company.com&gt;";
  </code></pre>
  
  <p>etc...</p>
  
  <p>In order to write a generic decoding function, we need to extract:</p>
  
  <ul>
  <li><p>the charset (utf-8, Windows1258, etc...)</p></li>
  <li><p>the transfert encoding type (quoted printable or base 64)</p></li>
  <li><p>the encoded string</p></li>
  </ul>
  
  <p>Any idea how to extract the pattern between ?xxx?Q? or ?xxx?B? </p>
  
  <p>Note: this can be uppercase or lowercase</p>
  
  <p>Thanks.</p>